Class: FlexYear::RangeParser
- Inherits:
-
Object
- Object
- FlexYear::RangeParser
- Defined in:
- lib/flexyear/range_parsers/range_parser.rb
Direct Known Subclasses
AfterParser, AsteriskParser, BeforeParser, CircaParser, DecadeParser, EarlyParser, LateParser, MidParser, SpecificYearParser, YearRangeParser
Class Attribute Summary collapse
-
.parser_classes ⇒ Object
readonly
Returns the value of attribute parser_classes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(string) ⇒ RangeParser
constructor
A new instance of RangeParser.
Constructor Details
#initialize(string) ⇒ RangeParser
Returns a new instance of RangeParser.
27 28 29 |
# File 'lib/flexyear/range_parsers/range_parser.rb', line 27 def initialize(string) @string = string end |
Class Attribute Details
.parser_classes ⇒ Object (readonly)
Returns the value of attribute parser_classes.
4 5 6 |
# File 'lib/flexyear/range_parsers/range_parser.rb', line 4 def parser_classes @parser_classes end |
Class Method Details
.find_parser(string) ⇒ Object
15 16 17 18 19 20 21 |
# 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) ⇒ Object
23 24 25 |
# File 'lib/flexyear/range_parsers/range_parser.rb', line 23 def self.inherited(subclass) RangeParser.parser_classes << subclass end |
.parse(string) ⇒ Object
9 10 11 12 13 |
# 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 |