Class: BibleRef::Languages::Base
- Inherits:
-
Object
- Object
- BibleRef::Languages::Base
show all
- Defined in:
- lib/bible_ref/languages/base.rb
Instance Method Summary
collapse
Instance Method Details
#book_id(book_name, canon) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/bible_ref/languages/base.rb', line 8
def book_id(book_name, canon)
book_name = replace_roman_numerals(book_name)
return book_name.upcase if books[book_name.upcase]
canon.books.each do |book|
details = books[book]
next if details.nil?
if (match = details[:match])
return book if book_name.downcase =~ match || book_name =~ match
else
return book if book_name.downcase == details[:name].downcase || book_name == details[:name]
end
end
nil
end
|
#book_name(book_name, canon) ⇒ Object
24
25
26
27
|
# File 'lib/bible_ref/languages/base.rb', line 24
def book_name(book_name, canon)
return unless id = book_id(book_name, canon)
books[id][:name]
end
|
#books ⇒ Object
4
5
6
|
# File 'lib/bible_ref/languages/base.rb', line 4
def books
fail NotImplementedError, "You must override #books in your language class."
end
|
#replace_roman_numerals(book) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/bible_ref/languages/base.rb', line 29
def replace_roman_numerals(book)
book.sub!(/^iii |^III /i, '3 ')
book.sub!(/^ii |^II /i, '2 ')
book.sub!(/^i |^I /i, '1 ')
book
end
|