class FlexYear::RangeParser

Attributes

parser_classes[R]

Public Class Methods

find_parser(string) click to toggle source
# File lib/flexyear/range_parsers/range_parser.rb, line 15
def self.find_parser(string)
  parser_class = RangeParser.parser_classes.find do |klass|
    klass.can_parse?(string)
  end
  return parser_class.new(string) if parser_class
  nil
end
inherited(subclass) click to toggle source
# File lib/flexyear/range_parsers/range_parser.rb, line 23
def self.inherited(subclass)
  RangeParser.parser_classes << subclass
end
new(string) click to toggle source
# File lib/flexyear/range_parsers/range_parser.rb, line 27
def initialize(string)
  @string = string
end
parse(string) click to toggle source
# File lib/flexyear/range_parsers/range_parser.rb, line 9
def self.parse(string)
  parser = find_parser(string)
  return nil unless parser
  parser.parse
end