m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/lib/songs.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/songs.rb')
-rw-r--r--lib/songs.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/songs.rb b/lib/songs.rb
new file mode 100644
index 0000000..aa519e1
--- /dev/null
+++ b/lib/songs.rb
@@ -0,0 +1,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