Class: KjLite::Chapter
- Inherits:
-
Object
- Object
- KjLite::Chapter
- Defined in:
- lib/kjlite.rb
Instance Attribute Summary collapse
-
#book_id ⇒ Object
readonly
Returns the value of attribute book_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(allverses, id, book_id, book_name, debug: false) ⇒ Chapter
constructor
A new instance of Chapter.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #verse(n) ⇒ Object
- #verses(*list) ⇒ Object
Constructor Details
#initialize(allverses, id, book_id, book_name, debug: false) ⇒ Chapter
Returns a new instance of Chapter.
44 45 46 47 |
# File 'lib/kjlite.rb', line 44 def initialize(allverses, id, book_id, book_name, debug: false) @verses, @id, @book_id, @debug = allverses, id, book_id, debug @book_name = book_name end |
Instance Attribute Details
#book_id ⇒ Object (readonly)
Returns the value of attribute book_id.
42 43 44 |
# File 'lib/kjlite.rb', line 42 def book_id @book_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
42 43 44 |
# File 'lib/kjlite.rb', line 42 def id @id end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
42 43 44 |
# File 'lib/kjlite.rb', line 42 def number @number end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
42 43 44 |
# File 'lib/kjlite.rb', line 42 def title @title end |
Instance Method Details
#inspect ⇒ Object
71 72 73 |
# File 'lib/kjlite.rb', line 71 def inspect() "#<KjLite::Chapter @id=#{@id} @book_id=#{@book_id} @number=#{@id}>" end |
#to_s ⇒ Object
79 80 81 |
# File 'lib/kjlite.rb', line 79 def to_s() title() end |
#verse(n) ⇒ Object
49 50 51 |
# File 'lib/kjlite.rb', line 49 def verse(n) verses(n).text end |
#verses(*list) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/kjlite.rb', line 53 def verses(*list) puts 'inside verses' if @debug list = list.first.to_a if list.first.is_a? Range if list.empty? then return @verses.map.with_index {|x,i| Verse.new @book_name, @id, i+1, x} elsif list.length < 2 Verse.new @book_name, @id, list.first, @verses[list.first.to_i-1] else list.flatten.map do |n| Verse.new @book_name, @id, n, @verses[n.to_i-1] end end end |