lib/hyakunin-issyu.rb in hyakunin-issyu-0.0.8 vs lib/hyakunin-issyu.rb in hyakunin-issyu-0.1.0
- old
+ new
@@ -1,23 +1,20 @@
#encoding: utf-8
require 'hyakunin-issyu/version'
-require 'yaml'
-path = Dir.pwd + '/vendor/bundle/ruby/1.9.1/gems/hyakunin-issyu-0.0.8/lib/hyakunin-issyu/data.yml'
-@data = YAML.load_file(path)
+ require 'yaml'
+ # path = Dir.pwd + '/vendor/bundle/ruby/1.9.1/gems/hyakunin-issyu-0.0.8/lib/hyakunin-issyu/data.yml'
+ path = 'lib/hyakunin-issyu/data.yml'
+ @data_set = YAML.load_file(path)
module HyakuninIssyu
- def self.songs(start=1,last=1)
- new_data = Hash.new
- for i in start..last do
- new_data[i] = @data[i]
- end
- return new_data
+ def initialize
+ HyakuninIssyu.const_set("SONGS", @data_set)
end
- def self.poem(id=1)
- @data[id]['poem']
- end
-
- def self.poet(id=1)
- @data[id]['poet']
+ def songs(id_from, id_to)
+ @songs = Array.new
+ for i in id_from..id_to
+ song = HyakuninIssyu.const_get("SONGS")
+ @songs[i] = song[i]
+ end
end
end