Class: OData::Properties::DateTime
- Inherits:
-
OData::Property
- Object
- OData::Property
- OData::Properties::DateTime
- Defined in:
- lib/odata/properties/date_time.rb
Overview
Defines the DateTime OData type.
Instance Attribute Summary
Attributes inherited from OData::Property
Instance Method Summary collapse
-
#type ⇒ Object
The OData type name.
-
#url_value ⇒ String
Value to be used in URLs.
-
#value ⇒ DateTime?
Returns the property value, properly typecast.
-
#value=(new_value) ⇒ Object
Sets the property value.
Methods inherited from OData::Property
#==, #allows_nil?, #concurrency_mode, #initialize, #to_xml, #xml_value
Constructor Details
This class inherits a constructor from OData::Property
Instance Method Details
#type ⇒ Object
The OData type name
27 28 29 |
# File 'lib/odata/properties/date_time.rb', line 27 def type 'Edm.DateTime' end |
#url_value ⇒ String
Value to be used in URLs.
33 34 35 |
# File 'lib/odata/properties/date_time.rb', line 33 def url_value "datetime'#{value}'" end |
#value ⇒ DateTime?
Returns the property value, properly typecast
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/odata/properties/date_time.rb', line 7 def value if (@value.nil? || @value.empty?) && allows_nil? nil else begin ::DateTime.strptime(@value, '%Y-%m-%dT%H:%M:%S.%L') rescue ArgumentError ::DateTime.parse(@value) end end end |
#value=(new_value) ⇒ Object
Sets the property value
21 22 23 24 |
# File 'lib/odata/properties/date_time.rb', line 21 def value=(new_value) validate(new_value) @value = parse_value(new_value) end |