class ActsAsScriptural

Attributes

chapters[RW]
parsed[RW]

Public Class Methods

new() click to toggle source
# File lib/acts_as_scriptural.rb, line 5
def initialize
  @chapters = Array.new
end

Public Instance Methods

add_chapters(parsed_reference) click to toggle source
# File lib/acts_as_scriptural.rb, line 20
def add_chapters(parsed_reference)
  for i in parsed_reference.first_book_index..parsed_reference.last_book_index do

    if (i == parsed_reference.first_book_index)
      first_chapter = parsed_reference.first_chapter
    else
      first_chapter = 1
    end

    if (i == parsed_reference.last_book_index)
      last_chapter = parsed_reference.last_chapter
    else
      last_chapter = bible.chapters_in_book(i)
    end

    for j in first_chapter..last_chapter
      @chapters << [i, j]
    end
  end
end
bible() click to toggle source
# File lib/acts_as_scriptural.rb, line 41
def bible
  @bible || Bible.new
end
lookup() click to toggle source
# File lib/acts_as_scriptural.rb, line 45
def lookup
  @lookup || AbbreviationLookup.new
end
parse(str) click to toggle source
# File lib/acts_as_scriptural.rb, line 9
def parse(str)
  unless str.nil?
    references = str.split(',')
    references.each do |ref| 
      parsed_reference = Parser.new.parse_reference(ref)
      add_chapters(parsed_reference) if parsed_reference
    end
  end
  self
end