Class: FlexYear

Inherits:
Object
  • Object
show all
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

Historical

Defined Under Namespace

Classes: AfterParser, AsteriskParser, BeforeParser, CircaParser, DecadeParser, EarlyParser, Historical, InvalidYearError, LateParser, MidParser, RangeParser, SpecificYearParser, YearRangeParser

Constant Summary collapse

VERSION =
"2.1.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(year_input) ⇒ FlexYear

Returns a new instance of FlexYear.



28
29
30
31
32
33
34
35
36
# File 'lib/flexyear.rb', line 28

def initialize(year_input)
  @year_input = year_input

  if year_input.is_a?(Array)
    parse_year_list(year_input)
  else
    parse_year_string(year_input)
  end
end

Instance Attribute Details

#year_highObject (readonly)

Returns the value of attribute year_high.



26
27
28
# File 'lib/flexyear.rb', line 26

def year_high
  @year_high
end

#year_lowObject (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_sObject



38
39
40
# File 'lib/flexyear.rb', line 38

def to_s
  @year_input
end