module TritonOps::Support::TypeCoercion::Coerce

Public Class Methods

to_bool(string) click to toggle source
# File lib/triton-ops/support/type_coercion.rb, line 44
def self.to_bool(string)
  case string
  when 'true'
    true
  when 'false'
    false
  end
end
to_string(time) click to toggle source
# File lib/triton-ops/support/type_coercion.rb, line 59
def self.to_string(time)
  time.utc.iso8601
end
to_time(string) click to toggle source
# File lib/triton-ops/support/type_coercion.rb, line 16
def self.to_time(string)
  if string =~ /^[[:digit:]]+$/
    self.to_time string.chars.take(10).join.to_i
  else
    Time.parse(string).utc
  end
end