Class: Gorillib::Factory::EpochTimeFactory

Inherits:
ConvertingFactory show all
Defined in:
lib/gorillib/type/extended.rb

Direct Known Subclasses

IntTimeFactory

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ConvertingFactory

#receive

Methods inherited from BaseFactory

blankish?, #blankish?, #initialize, native?, #native?, #receive, #typename

Constructor Details

This class inherits a constructor from Gorillib::Factory::BaseFactory

Class Method Details

.typenameObject



45
# File 'lib/gorillib/type/extended.rb', line 45

def self.typename() :epoch_time ; end

Instance Method Details

#convert(obj) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/gorillib/type/extended.rb', line 48

def convert(obj)
  case obj
  when Numeric           then obj.to_f
  when Time              then obj.to_f
  when /\A\d{14}Z?\z/    then Time.parse(obj)
  when String            then Time.parse_safely(obj).to_f
  end
end