Class: FlexYear
- Inherits:
-
Object
- Object
- FlexYear
- Defined in:
- lib/flexyear.rb,
lib/flexyear/version.rb,
lib/flexyear/range_parsers/mid_parser.rb,
lib/flexyear/range_parsers/late_parser.rb,
lib/flexyear/range_parsers/after_parser.rb,
lib/flexyear/range_parsers/circa_parser.rb,
lib/flexyear/range_parsers/early_parser.rb,
lib/flexyear/range_parsers/range_parser.rb,
lib/flexyear/range_parsers/before_parser.rb,
lib/flexyear/range_parsers/decade_parser.rb,
lib/flexyear/range_parsers/asterisk_parser.rb,
lib/flexyear/range_parsers/year_range_parser.rb,
lib/flexyear/range_parsers/specific_year_parser.rb
Overview
Represents a flexible year entry:
* 1979 - a specific year
* 1970s and 70s - decades
* mid-70s, early-70s, late-70s - subdecades, dashes optional
* 1972-1975 - a range
All years can be in two or four digit format
Direct Known Subclasses
Defined Under Namespace
Classes: AfterParser, AsteriskParser, BeforeParser, CircaParser, DecadeParser, EarlyParser, Historical, InvalidYearError, LateParser, MidParser, RangeParser, SpecificYearParser, YearRangeParser
Constant Summary collapse
- VERSION =
"2.0.0"
Instance Attribute Summary collapse
-
#year_high ⇒ Object
readonly
Returns the value of attribute year_high.
-
#year_low ⇒ Object
readonly
Returns the value of attribute year_low.
Instance Method Summary collapse
-
#initialize(year_string) ⇒ FlexYear
constructor
A new instance of FlexYear.
- #to_s ⇒ Object
Constructor Details
#initialize(year_string) ⇒ FlexYear
28 29 30 31 32 33 34 |
# File 'lib/flexyear.rb', line 28 def initialize(year_string) @year_string = year_string.to_s @low, @high = RangeParser.parse(@year_string) parse_year end |
Instance Attribute Details
#year_high ⇒ Object (readonly)
Returns the value of attribute year_high.
26 27 28 |
# File 'lib/flexyear.rb', line 26 def year_high @year_high end |
#year_low ⇒ Object (readonly)
Returns the value of attribute year_low.
26 27 28 |
# File 'lib/flexyear.rb', line 26 def year_low @year_low end |
Instance Method Details
#to_s ⇒ Object
36 37 38 |
# File 'lib/flexyear.rb', line 36 def to_s @year_string end |