class KjLite::Book
Attributes
id[R]
name[R]
permalink[R]
Public Class Methods
new(id, name, chapters, debug: false)
click to toggle source
# File lib/kjlite.rb, line 89 def initialize(id, name, chapters, debug: false) @id, @name, @debug = id, name, debug @permalink = name.downcase.gsub(/\s/,'-') puts 'chapters.length : ' + chapters.length.inspect if @debug @chapters = chapters.map.with_index do |x,i| Chapter.new x, i+1, id, name, debug: @debug end end
Public Instance Methods
chapter(n)
click to toggle source
# File lib/kjlite.rb, line 100 def chapter(n) chapters n end
chapters(*args)
click to toggle source
# File lib/kjlite.rb, line 104 def chapters(*args) puts 'args: ' + args.inspect if @debug if args.empty? then return @chapters elsif args.length < 2 @chapters[args.first.to_i-1] else args.flatten.map {|n| @chapters[n-1] }.compact end end
inspect()
click to toggle source
# File lib/kjlite.rb, line 118 def inspect() "#<KjLite::Book @name=#{@name.inspect} @chapters=#{@chapters.inspect}>" end
to_s()
click to toggle source
# File lib/kjlite.rb, line 122 def to_s() @chapters end