class Hyrax::Ingest::Transformer::ToDate

Attributes

orig_format[R]

Public Class Methods

new(orig_format) click to toggle source
# File lib/hyrax/ingest/transformer/to_date.rb, line 9
def initialize(orig_format)
  @orig_format = orig_format.to_sym
end

Public Instance Methods

transform(value) click to toggle source
# File lib/hyrax/ingest/transformer/to_date.rb, line 13
def transform(value)
  return transform_multiple(value) if value.respond_to?(:each)
  case orig_format
  when :from_timestamp_with_ms
    DateTime.strptime(value, '%Q')
  when :"from_yyyy-mm-dd"
    DateTime.parse(value)
  else
    raise Hyrax::Ingest::Errors::UnrecognizedTransformOption.new(orig_format)
  end
end

Private Instance Methods

transform_multiple(values) click to toggle source
# File lib/hyrax/ingest/transformer/to_date.rb, line 27
def transform_multiple(values)
  values.map { |value| transform(value) }
end