Class: Watchtower
- Inherits:
-
Object
- Object
- Watchtower
- Defined in:
- lib/bible_robot/watchtower.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
Returns the value of attribute page.
-
#robot ⇒ Object
Returns the value of attribute robot.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #book_list ⇒ Object
- #book_url(book) ⇒ Object
- #chapter_url(book, chapter) ⇒ Object
- #chapters(book) ⇒ Object
-
#initialize(robot, url = "http://www.watchtower.org/t/biblia/") ⇒ Watchtower
constructor
A new instance of Watchtower.
- #verse(book, chapter, begin_verse, end_verse = begin_verse) ⇒ Object
- #verses(book, chapter) ⇒ Object
Constructor Details
#initialize(robot, url = "http://www.watchtower.org/t/biblia/") ⇒ Watchtower
11 12 13 14 15 16 |
# File 'lib/bible_robot/watchtower.rb', line 11 def initialize robot, url="http://www.watchtower.org/t/biblia/" @url = url @robot = robot @map = {} @verses = {} end |
Instance Attribute Details
#page ⇒ Object
Returns the value of attribute page.
9 10 11 |
# File 'lib/bible_robot/watchtower.rb', line 9 def page @page end |
#robot ⇒ Object
Returns the value of attribute robot.
9 10 11 |
# File 'lib/bible_robot/watchtower.rb', line 9 def robot @robot end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/bible_robot/watchtower.rb', line 8 def url @url end |
Instance Method Details
#book_list ⇒ Object
18 19 20 |
# File 'lib/bible_robot/watchtower.rb', line 18 def book_list book_map.keys end |
#book_url(book) ⇒ Object
22 23 24 |
# File 'lib/bible_robot/watchtower.rb', line 22 def book_url book book_map[book] if book_exists? book end |
#chapter_url(book, chapter) ⇒ Object
26 27 28 |
# File 'lib/bible_robot/watchtower.rb', line 26 def chapter_url book, chapter chapter_map(book_map[book])[chapter] if book_exists? book end |
#chapters(book) ⇒ Object
30 31 32 |
# File 'lib/bible_robot/watchtower.rb', line 30 def chapters book chapter_map(book_map[book]).size if book_exists? book end |
#verse(book, chapter, begin_verse, end_verse = begin_verse) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bible_robot/watchtower.rb', line 42 def verse book, chapter, begin_verse, end_verse=begin_verse verses_in_range = "" if verses_exists? book, chapter, begin_verse, end_verse (begin_verse..end_verse).each do |v| url = chapter_url(book, chapter) verses_in_range.concat(verse_map(url)[v]) verses_in_range.concat(" ") unless end_verse == v end else raise "invalid verse(s)" end verses_in_range end |
#verses(book, chapter) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/bible_robot/watchtower.rb', line 34 def verses book, chapter if chapter_exists? book, chapter verse_map(chapter_url(book,chapter)).size end end |