Class: BibleRef::Languages::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bible_ref/languages/base.rb

Direct Known Subclasses

Cherokee, Czech, English, Latin, Portuguese, Romanian

Instance Method Summary collapse

Instance Method Details

#book_id(book_name, canon) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bible_ref/languages/base.rb', line 13

def book_id(book_name, canon)
  book_name = replace_roman_numerals(book_name)
  return book_name.upcase if books[book_name.upcase] # already normalized
  canon.books.each do |book|
    details = books[book]
    next if details.nil?
    if (match = details[:match])
      return book if book_name.downcase =~ match
    else
      return book if book_name.downcase == details[:name].downcase
    end
  end
  nil
end

#book_name(book_name, canon) ⇒ Object



28
29
30
31
# File 'lib/bible_ref/languages/base.rb', line 28

def book_name(book_name, canon)
  return unless id = book_id(book_name, canon)
  books[id][:name]
end

#booksObject



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

#has_single_chapter?(reference) ⇒ Boolean

Is it a single chapter book?

Returns:

  • (Boolean)


9
10
11
# File 'lib/bible_ref/languages/base.rb', line 9

def has_single_chapter?(reference)
  fail NotImplementedError, "You must override #has_single_chapter? in your language class."
end

#replace_roman_numerals(book) ⇒ Object



33
34
35
36
37
38
# File 'lib/bible_ref/languages/base.rb', line 33

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