Class: FrOData::Properties::Decimal

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

Overview

Defines the Decimal FrOData type.

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, #json_value, #strict?, #to_xml, #xml_value

Constructor Details

This class inherits a constructor from FrOData::Property

Instance Method Details

#typeObject

The FrOData type name



23
24
25
# File 'lib/frodata/properties/decimal.rb', line 23

def type
  'Edm.Decimal'
end

#url_valueString

Value to be used in URLs.

Returns:



29
30
31
# File 'lib/frodata/properties/decimal.rb', line 29

def url_value
  "#{value.to_f}"
end

#valueBigDecimal?

Returns the property value, properly typecast

Returns:

  • (BigDecimal, nil)


7
8
9
10
11
12
13
# File 'lib/frodata/properties/decimal.rb', line 7

def value
  if (@value.nil? || @value.empty?) && (strict? && allows_nil?)
    nil
  else
    BigDecimal(@value)
  end
end

#value=(new_value) ⇒ Object

Sets the property value



17
18
19
20
# File 'lib/frodata/properties/decimal.rb', line 17

def value=(new_value)
  validate(BigDecimal(new_value.to_s))
  @value = new_value.to_s
end