Class: Alchemrest::Transforms::EpochTime
- Inherits:
-
Morpher::Transform
- Object
- Morpher::Transform
- Alchemrest::Transforms::EpochTime
- Defined in:
- lib/alchemrest/transforms/epoch_time.rb
Instance Method Summary collapse
Instance Method Details
#call(input) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/alchemrest/transforms/epoch_time.rb', line 10 def call(input) if input.is_a?(Integer) as_seconds = case unit when :seconds input when :milliseconds input / 1000 else raise "Invalid unit #{unit}" end success(Time.at(as_seconds).in_time_zone("UTC")) else failure( error( message: "Expected #{input} to be an epoch integer", input: input, ), ) end end |