Class: CBETA::Canon
- Inherits:
-
Object
- Object
- CBETA::Canon
- Defined in:
- lib/cbeta/canon.rb
Instance Method Summary collapse
- #get_canon_attr(canon_id, attr_name) ⇒ Object
-
#initialize ⇒ Canon
constructor
A new instance of Canon.
Constructor Details
#initialize ⇒ Canon
Returns a new instance of Canon.
4 5 6 7 8 9 10 11 12 |
# File 'lib/cbeta/canon.rb', line 4 def initialize fn = File.join(File.dirname(__FILE__), '../data/canons.csv') text = File.read(fn) @canons = {} CSV.parse(text, :headers => true) do |row| id = row['id'] @canons[id] = row end end |
Instance Method Details
#get_canon_attr(canon_id, attr_name) ⇒ Object
14 15 16 |
# File 'lib/cbeta/canon.rb', line 14 def get_canon_attr(canon_id, attr_name) @canons[canon_id][attr_name] end |