class Rasti::Types::Time

Attributes

format[R]

Public Class Methods

[](format) click to toggle source
# File lib/rasti/types/time.rb, line 9
def self.[](format)
  new format
end
new(format) click to toggle source
# File lib/rasti/types/time.rb, line 20
def initialize(format)
  @format = format
end

Public Instance Methods

inspect()
Alias for: to_s
to_s() click to toggle source
# File lib/rasti/types/time.rb, line 13
def to_s
  "#{self.class}['#{format}']"
end
Also aliased as: inspect

Private Instance Methods

string_to_time(value) click to toggle source
# File lib/rasti/types/time.rb, line 32
def string_to_time(value)
  ::Time.strptime(value, format)
end
transform(value) click to toggle source
# File lib/rasti/types/time.rb, line 28
def transform(value)
  value.is_a?(::String) ? string_to_time(value) : value.to_time
end
valid?(value) click to toggle source
# File lib/rasti/types/time.rb, line 24
def valid?(value)
  value.is_a?(::String) || value.respond_to?(:to_time)
end