Class: OData::Properties::Decimal
- Inherits:
-
OData::Property
- Object
- OData::Property
- OData::Properties::Decimal
- Defined in:
- lib/odata/properties/decimal.rb
Overview
Defines the Decimal 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 ⇒ BigDecimal?
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
23 24 25 |
# File 'lib/odata/properties/decimal.rb', line 23 def type 'Edm.Decimal' end |
#url_value ⇒ String
Value to be used in URLs.
29 30 31 |
# File 'lib/odata/properties/decimal.rb', line 29 def url_value "#{value.to_f}M" end |
#value ⇒ BigDecimal?
Returns the property value, properly typecast
7 8 9 10 11 12 13 |
# File 'lib/odata/properties/decimal.rb', line 7 def value if (@value.nil? || @value.empty?) && allows_nil? nil else BigDecimal(@value) end end |
#value=(new_value) ⇒ Object
Sets the property value
17 18 19 20 |
# File 'lib/odata/properties/decimal.rb', line 17 def value=(new_value) validate(BigDecimal(new_value.to_s)) @value = new_value.to_s end |