Class: FrOData::Properties::DateTime
- Inherits:
-
FrOData::Property
- Object
- FrOData::Property
- FrOData::Properties::DateTime
- Defined in:
- lib/frodata/properties/date_time.rb
Overview
Defines the DateTime FrOData type.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from FrOData::Property
Instance Method Summary collapse
-
#json_value ⇒ String
Value to be used in JSON.
-
#type ⇒ Object
The FrOData 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.
-
#xml_value ⇒ String
Value to be used in JSON.
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_value ⇒ String
Value to be used in JSON.
39 40 41 |
# File 'lib/frodata/properties/date_time.rb', line 39 def json_value xml_value end |
#type ⇒ Object
The FrOData type name
27 28 29 |
# File 'lib/frodata/properties/date_time.rb', line 27 def type 'Edm.DateTime' end |
#url_value ⇒ String
Value to be used in URLs.
45 46 47 |
# File 'lib/frodata/properties/date_time.rb', line 45 def url_value xml_value end |
#value ⇒ DateTime?
Returns the property value, properly typecast
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_value ⇒ String
Value to be used in JSON.
33 34 35 |
# File 'lib/frodata/properties/date_time.rb', line 33 def xml_value @value.andand.sub(/[\+\-]00:00$/, 'Z') end |