Class: FrOData::Properties::DateTime

Inherits:
FrOData::Property show all
Defined in:
lib/frodata/properties/date_time.rb

Overview

Defines the DateTime FrOData type.

Direct Known Subclasses

Date, DateTimeOffset, TimeOfDay

Instance Attribute Summary

Attributes inherited from FrOData::Property

#name, #options

Instance Method Summary collapse

Methods inherited from FrOData::Property

#==, #allows_nil?, #concurrency_mode, from_xml, #initialize, #strict?, #to_xml

Constructor Details

This class inherits a constructor from FrOData::Property

Instance Method Details

#json_valueString

Value to be used in JSON.

Returns:



39
40
41
# File 'lib/frodata/properties/date_time.rb', line 39

def json_value
  xml_value
end

#typeObject

The FrOData type name



27
28
29
# File 'lib/frodata/properties/date_time.rb', line 27

def type
  'Edm.DateTime'
end

#url_valueString

Value to be used in URLs.

Returns:



45
46
47
# File 'lib/frodata/properties/date_time.rb', line 45

def url_value
  xml_value
end

#valueDateTime?

Returns the property value, properly typecast

Returns:



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/frodata/properties/date_time.rb', line 7

def value
  if (@value.nil? || @value.empty?) && allows_nil?
    nil
  else
    begin
      date_class.strptime(@value, strptime_format)
    rescue ArgumentError
      date_class.parse(@value)
    end
  end
end

#value=(new_value) ⇒ Object

Sets the property value



21
22
23
24
# File 'lib/frodata/properties/date_time.rb', line 21

def value=(new_value)
  validate(new_value)
  @value = parse_value(new_value)
end

#xml_valueString

Value to be used in JSON.

Returns:



33
34
35
# File 'lib/frodata/properties/date_time.rb', line 33

def xml_value
  @value.andand.sub(/[\+\-]00:00$/, 'Z')
end