Class: Stanford::Mods::Imprint::DateRange

Inherits:
Object
  • Object
show all
Defined in:
lib/stanford-mods/imprint.rb

Instance Method Summary collapse

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_valueObject

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_valuesObject

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

#encodingObject

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_valueObject

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