Class: ActsAsScriptural::Bible
- Inherits:
-
Object
- Object
- ActsAsScriptural::Bible
- Defined in:
- lib/acts_as_scriptural/bible.rb
Instance Attribute Summary collapse
-
#indexhash ⇒ Object
Returns the value of attribute indexhash.
-
#namehash ⇒ Object
Returns the value of attribute namehash.
Instance Method Summary collapse
- #book_names ⇒ Object
- #chapter_exists?(book_index, chapter_number) ⇒ Boolean
- #chapters_in_book(book_index) ⇒ Object
-
#initialize ⇒ Bible
constructor
A new instance of Bible.
Constructor Details
#initialize ⇒ Bible
Returns a new instance of Bible.
7 8 9 10 11 12 |
# File 'lib/acts_as_scriptural/bible.rb', line 7 def initialize # two lookup tables...not too DRY @namehash = Hash.new @indexhash = Hash.new import_from_file end |
Instance Attribute Details
#indexhash ⇒ Object
Returns the value of attribute indexhash.
5 6 7 |
# File 'lib/acts_as_scriptural/bible.rb', line 5 def indexhash @indexhash end |
#namehash ⇒ Object
Returns the value of attribute namehash.
5 6 7 |
# File 'lib/acts_as_scriptural/bible.rb', line 5 def namehash @namehash end |
Instance Method Details
#book_names ⇒ Object
14 15 16 |
# File 'lib/acts_as_scriptural/bible.rb', line 14 def book_names @namehash.map{|k,v| v.name} end |
#chapter_exists?(book_index, chapter_number) ⇒ Boolean
18 19 20 21 |
# File 'lib/acts_as_scriptural/bible.rb', line 18 def chapter_exists?(book_index, chapter_number) @indexhash[book_index] && chapter_number.between?(1, @indexhash[book_index].num_chapters) end |
#chapters_in_book(book_index) ⇒ Object
23 24 25 |
# File 'lib/acts_as_scriptural/bible.rb', line 23 def chapters_in_book(book_index) @indexhash[book_index].num_chapters end |