class BiblePassage::BookKeyTranslator

Constants

TRANSLATIONS

Private Class Methods

translations() click to toggle source
# File lib/bible_passage/book_key_translator.rb, line 88
def self.translations
  @@translations ||= Hash[
    TRANSLATIONS.flat_map do |book, abbrevs|
      abbrevs.map do |abbrev|
        [abbrev, book]
      end
    end
  ]
end

Public Instance Methods

keyify(book_name, raise_errors = true) click to toggle source
# File lib/bible_passage/book_key_translator.rb, line 74
def keyify(book_name, raise_errors = true)
  translation = BookKeyTranslator.translations[normalize_input(book_name)]
  if translation
    return translation
  elsif raise_errors
    raise(InvalidReferenceError.new("#{book_name} is not a valid book"))
  end
end

Private Instance Methods

normalize_input(book_name) click to toggle source
# File lib/bible_passage/book_key_translator.rb, line 84
def normalize_input(book_name)
  book_name.strip.downcase.gsub(/\s+/, ' ').to_sym
end