Module: Windoo::Converters

Defined in:
lib/windoo/converters.rb

Overview

Methods for converting values in standard ways Usually used for converting between Ruby values and JSON values between Windoo and the Server

Class Method Summary collapse

Class Method Details

.time_to_api(time) ⇒ String

Returns The time in UTC and ISO8601 format.

Parameters:

  • time (Time)

    a Time object to send to the API

Returns:

  • (String)

    The time in UTC and ISO8601 format



17
18
19
# File 'lib/windoo/converters.rb', line 17

def self.time_to_api(time)
  time.utc.iso8601
end

.to_time(time) ⇒ Time

Returns The timestamp as a Time object.

Parameters:

  • time (#to_s)

    a timestamp from the API

Returns:

  • (Time)

    The timestamp as a Time object



23
24
25
26
27
# File 'lib/windoo/converters.rb', line 23

def self.to_time(time)
  return time if time.is_a? Time

  Time.parse time.to_s
end