Class: ActsAsScriptural::Bible

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_scriptural/bible.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBible

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

#indexhashObject

Returns the value of attribute indexhash.



5
6
7
# File 'lib/acts_as_scriptural/bible.rb', line 5

def indexhash
  @indexhash
end

#namehashObject

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_namesObject



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

Returns:

  • (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