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 = [], other = []) ⇒ NormalizedDate
constructor
A new instance of NormalizedDate.
-
#to_s ⇒ String
The normalized title/date.
Constructor Details
#initialize(inclusive, bulk = [], other = []) ⇒ NormalizedDate
Returns a new instance of NormalizedDate.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/arclight/normalized_date.rb', line 12 def initialize(inclusive, bulk = [], other = []) @inclusive = (inclusive || []).map do |inclusive_text| if inclusive_text.is_a? Array # of YYYY-YYYY for ranges # NOTE: This code is not routable AFAICT in actual indexing. # We pass arrays of strings (or xml nodes) here, and never a multidimensional array year_range(inclusive_text) elsif inclusive_text.present? inclusive_text.strip end end&.join(', ') @bulk = Array.wrap(bulk).compact.map(&:strip).join(', ') @other = Array.wrap(other).compact.map(&:strip).join(', ') end |
Instance Method Details
#to_s ⇒ String
Returns the normalized title/date.
28 29 30 |
# File 'lib/arclight/normalized_date.rb', line 28 def to_s normalize end |