class Coppertone::RecordTermParser

Parses a record into terms

Constants

ALLOWED_CHARACTERS
RECORD_REGEXP
VERSION_STR

Attributes

terms[R]
text[R]

Public Class Methods

new(text) click to toggle source
# File lib/coppertone/record_term_parser.rb, line 17
def initialize(text)
  raise RecordParsingError unless self.class.record?(text)
  raise RecordParsingError unless ALLOWED_CHARACTERS.match?(text)

  @text = text
  @terms = Coppertone::TermsParser.new(terms_segment).terms
end
record?(text) click to toggle source
# File lib/coppertone/record_term_parser.rb, line 8
def self.record?(text)
  return false if text.blank?
  return true if RECORD_REGEXP.match?(text.strip)

  false
end

Public Instance Methods

terms_segment() click to toggle source
# File lib/coppertone/record_term_parser.rb, line 25
def terms_segment
  text[VERSION_STR.length..].strip
end