Class: Scriptura::ScriptureChapter
- Inherits:
-
Object
- Object
- Scriptura::ScriptureChapter
- Defined in:
- lib/scriptura/scripture_chapter.rb
Defined Under Namespace
Classes: DoesNotExist
Instance Attribute Summary collapse
-
#chapter_number ⇒ Object
(also: #number)
readonly
Returns the value of attribute chapter_number.
-
#scripture_book ⇒ Object
readonly
Returns the value of attribute scripture_book.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #first_verse ⇒ Object
- #first_verse_number ⇒ Object
-
#initialize(book_number, chapter_number) ⇒ ScriptureChapter
constructor
A new instance of ScriptureChapter.
- #last_verse ⇒ Object
- #last_verse_number ⇒ Object
- #number_of_verses ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(book_number, chapter_number) ⇒ ScriptureChapter
Returns a new instance of ScriptureChapter.
9 10 11 12 13 14 15 |
# File 'lib/scriptura/scripture_chapter.rb', line 9 def initialize(book_number, chapter_number) @scripture_book = ScriptureBook.new(book_number) fail ArgumentError, 'chapter number cannot be converted to an integer' unless chapter_number.respond_to?(:to_i) fail 'book number should be within 1-66' unless (1..66).cover?(book_number.to_i) @chapter_number = chapter_number.to_i fail DoesNotExist, 'chapter does not exist' if chapter_hash.nil? end |
Instance Attribute Details
#chapter_number ⇒ Object (readonly) Also known as: number
Returns the value of attribute chapter_number.
6 7 8 |
# File 'lib/scriptura/scripture_chapter.rb', line 6 def chapter_number @chapter_number end |
#scripture_book ⇒ Object (readonly)
Returns the value of attribute scripture_book.
5 6 7 |
# File 'lib/scriptura/scripture_chapter.rb', line 5 def scripture_book @scripture_book end |
Instance Method Details
#==(other) ⇒ Object
41 42 43 44 45 |
# File 'lib/scriptura/scripture_chapter.rb', line 41 def ==(other) return false unless other.is_a?(ScriptureChapter) scripture_book == other.scripture_book && chapter_number == other.chapter_number end |
#first_verse ⇒ Object
21 22 23 |
# File 'lib/scriptura/scripture_chapter.rb', line 21 def first_verse @first_verse = ScriptureVerse.new(scripture_book.number, number, 1) end |
#first_verse_number ⇒ Object
29 30 31 |
# File 'lib/scriptura/scripture_chapter.rb', line 29 def first_verse_number first_verse.number end |
#last_verse ⇒ Object
25 26 27 |
# File 'lib/scriptura/scripture_chapter.rb', line 25 def last_verse @first_verse = ScriptureVerse.new(scripture_book.number, number, number_of_verses) end |
#last_verse_number ⇒ Object
33 34 35 |
# File 'lib/scriptura/scripture_chapter.rb', line 33 def last_verse_number last_verse.number end |
#number_of_verses ⇒ Object
17 18 19 |
# File 'lib/scriptura/scripture_chapter.rb', line 17 def number_of_verses chapter_hash['verses'] end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/scriptura/scripture_chapter.rb', line 37 def to_s "#{scripture_book} #{@chapter_number}" end |