m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/lib/songs.rb
blob: aa519e105dd9c7de112c91060eb5a854c5927772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'set'

require './lib/util'

@songs = nil

def get_song_ids dir
  ids = Set.new
  Dir.new(src SongsDir).children.each do |filename|
    ids.add(File.basename filename, '.*')
  end
  ids
end

def songs
  @songs ||= get_song_ids(SongsDir).map do |song_id|
    [song_id, Song.from_yaml(song_id)]
  end.to_h
end