Class: Arclight::NormalizedDate
- Inherits:
-
Object
- Object
- Arclight::NormalizedDate
- Defined in:
- lib/arclight/normalized_date.rb
Overview
A utility class to normalize dates, typically by joining inclusive and bulk dates e.g., “1990-2000, bulk 1990-1999”
Instance Method Summary collapse
-
#initialize(inclusive, bulk = nil, other = nil) ⇒ NormalizedDate
constructor
A new instance of NormalizedDate.
-
#to_s ⇒ String
The normalized title/date.
Constructor Details
#initialize(inclusive, bulk = nil, other = nil) ⇒ NormalizedDate
Returns a new instance of NormalizedDate.
12 13 14 15 16 17 18 19 20 |
# File 'lib/arclight/normalized_date.rb', line 12 def initialize(inclusive, bulk = nil, other = nil) if inclusive.is_a? Array # of YYYY-YYYY for ranges @inclusive = YearRange.new(inclusive.include?('/') ? inclusive : inclusive.map { |v| v.tr('-', '/') }).to_s elsif inclusive.present? @inclusive = inclusive.strip end @bulk = bulk.strip if bulk.present? @other = other.strip if other.present? end |
Instance Method Details
#to_s ⇒ String
Returns the normalized title/date.
23 24 25 |
# File 'lib/arclight/normalized_date.rb', line 23 def to_s normalize end |