Class: KjLite::Chapter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (readonly)

Returns the value of attribute book_id.



42
43
44
# File 'lib/kjlite.rb', line 42

def book_id
  @book_id
end

#idObject (readonly)

Returns the value of attribute id.



42
43
44
# File 'lib/kjlite.rb', line 42

def id
  @id
end

#numberObject (readonly)

Returns the value of attribute number.



42
43
44
# File 'lib/kjlite.rb', line 42

def number
  @number
end

#titleObject (readonly)

Returns the value of attribute title.



42
43
44
# File 'lib/kjlite.rb', line 42

def title
  @title
end

Instance Method Details

#inspectObject



71
72
73
# File 'lib/kjlite.rb', line 71

def inspect()
  "#<KjLite::Chapter @id=#{@id} @book_id=#{@book_id} @number=#{@id}>"
end

#to_sObject



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