Class: Bible::BibleRefParser::Book::MultipleBooks
- Inherits:
-
Object
- Object
- Bible::BibleRefParser::Book::MultipleBooks
show all
- Defined in:
- lib/bible/parser.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of MultipleBooks.
292
293
294
|
# File 'lib/bible/parser.rb', line 292
def initialize(single)
@books = [single]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
328
329
330
331
332
333
334
335
336
337
|
# File 'lib/bible/parser.rb', line 328
def method_missing(sym, *args)
if ! @fixedUp
@books.last.__send__(sym, *args)
else
super(sym, *args)
end
end
|
Instance Method Details
#<<(value) ⇒ Object
303
304
305
306
307
308
309
310
311
312
313
314
315
|
# File 'lib/bible/parser.rb', line 303
def <<(value)
unless value.nil? || @books.last.nil?
Books[@books.last.book_symbol].succ.upto(value) { |book_info|
@books << SingleBook.new(book_info.book)
}
else
if value.nil?
@books << value
else
@books << SingleBook.new(value)
end
end
end
|
#==(value) ⇒ Object
321
322
323
324
325
326
|
# File 'lib/bible/parser.rb', line 321
def ==(value)
raise "Can't compare multipe books to single book" unless value.is_a?(Array)
@books.compact.each_with_index { |b, idx|
raise "Don't know how to compare to book #{value[idx]}" unless value[idx].is_a?(String) || value[idx].is_a?(Symbol)
}
end
|
#books ⇒ Object
317
318
319
|
# File 'lib/bible/parser.rb', line 317
def books
@books.compact
end
|
#fixup ⇒ Object
296
297
298
299
300
301
|
# File 'lib/bible/parser.rb', line 296
def fixup
if ! @fixedUp
@books.compact.each { |b| b.fixup }
@fixedUp = true
end
end
|
#inspect ⇒ Object
339
340
341
342
343
344
345
|
# File 'lib/bible/parser.rb', line 339
def inspect
@books.compact.inject("") { |val, b|
val << " " unless val.empty?
val << b.inspect
val
}
end
|