class FrOData::Properties::Time

Defines the Time FrOData type.

Public Instance Methods

type() click to toggle source

The FrOData type name

# File lib/frodata/properties/time.rb, line 23
def type
  'Edm.Time'
end
value() click to toggle source

Returns the property value, properly typecast @return [Time,nil]

# File lib/frodata/properties/time.rb, line 7
def value
  if (@value.nil? || @value.empty?) && allows_nil?
    nil
  else
    ::Time.strptime(@value, '%H:%M:%S%:z')
  end
end
value=(new_value) click to toggle source

Sets the property value @params new_value [Time]

# File lib/frodata/properties/time.rb, line 17
def value=(new_value)
  validate(new_value)
  @value = parse_value(new_value)
end

Private Instance Methods

parse_value(value) click to toggle source
# File lib/frodata/properties/time.rb, line 35
def parse_value(value)
  value.strftime('%H:%M:%S%:z')
end
validate(value) click to toggle source
# File lib/frodata/properties/time.rb, line 29
def validate(value)
  unless value.is_a?(::Time)
    validation_error 'Value is not a time object'
  end
end