Class: Stanford::Mods::Imprint::DateRange
- Inherits:
-
Object
- Object
- Stanford::Mods::Imprint::DateRange
- Defined in:
- lib/stanford-mods/imprint.rb
Instance Method Summary collapse
-
#base_value ⇒ Object
Base value as hyphen-joined string.
-
#base_values ⇒ Object
Base values as array.
-
#encoding ⇒ Object
The encoding value for the start of the range, or stop if not present.
-
#initialize(start: nil, stop: nil) ⇒ DateRange
constructor
A new instance of DateRange.
-
#qualified_value ⇒ Object
Decoded dates with “BCE” or “CE” and qualifier markers applied to the entire range, or individually if dates differ.
Constructor Details
#initialize(start: nil, stop: nil) ⇒ DateRange
Returns a new instance of DateRange.
233 234 235 236 |
# File 'lib/stanford-mods/imprint.rb', line 233 def initialize(start: nil, stop: nil) @start = start @stop = stop end |
Instance Method Details
#base_value ⇒ Object
Base value as hyphen-joined string. Used for comparison/deduping.
239 240 241 |
# File 'lib/stanford-mods/imprint.rb', line 239 def base_value "#{@start&.base_value}-#{@stop&.base_value}" end |
#base_values ⇒ Object
Base values as array. Used for comparison/deduping of individual dates.
244 245 246 |
# File 'lib/stanford-mods/imprint.rb', line 244 def base_values [@start&.base_value, @stop&.base_value].compact end |
#encoding ⇒ Object
The encoding value for the start of the range, or stop if not present.
249 250 251 |
# File 'lib/stanford-mods/imprint.rb', line 249 def encoding @start&.encoding || @stop&.encoding end |
#qualified_value ⇒ Object
Decoded dates with “BCE” or “CE” and qualifier markers applied to the entire range, or individually if dates differ.
255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/stanford-mods/imprint.rb', line 255 def qualified_value if @start&.qualifier == @stop&.qualifier qualifier = @start&.qualifier || @stop&.qualifier date = "#{@start&.decoded_value} - #{@stop&.decoded_value}" return "[ca. #{date}]" if qualifier == 'approximate' return "[#{date}?]" if qualifier == 'questionable' return "[#{date}]" if qualifier == 'inferred' date else "#{@start&.qualified_value} - #{@stop&.qualified_value}" end end |