class BibleBot::Bible

Defines Books and Regular Expressions used for parsing and other logic in this gem.

Public Class Methods

book_re() click to toggle source

compiled book regular expression

# File lib/bible_bot/bible.rb, line 547
def self.book_re
  @@book_re ||= Regexp.new(book_re_string, Regexp::IGNORECASE)
end
book_re_string() click to toggle source

assemble the book regex

# File lib/bible_bot/bible.rb, line 542
def self.book_re_string
  @@book_re_string ||= Bible.books.map(&:regex).join('|')
end
books() click to toggle source
# File lib/bible_bot/bible.rb, line 537
def self.books
  @@books
end
scripture_re() click to toggle source

compiled scripture reference regular expression

# File lib/bible_bot/bible.rb, line 552
def self.scripture_re
  @@scripture_re ||= Regexp.new(
    sprintf('\b' +
     '(?<BookTitle>%s)' +
     '[\s\.]*' +
     '(?<ChapterNumber>\d{1,3})' +
     '(?:\s*[:\.]\s*' +
     '(?<VerseNumber>\d{1,3}))?' +
     '(?:\s*-\s*' +
       '(?<EndBookTitle>%s)?[\s\.]*' +
       '(?<EndChapterNumber>\d{1,3})?' +
       '(?:\s*[:\.]\s*)?' +
       '(?<EndVerseNumber>\d{1,3})?' +
     ')?', book_re_string, book_re_string), Regexp::IGNORECASE)
end