Class: Gearbox::Types::Decimal
- Inherits:
-
Object
- Object
- Gearbox::Types::Decimal
- Includes:
- Gearbox::Type
- Defined in:
- lib/gearbox/types/decimal.rb
Overview
A Gearbox::Type for integer values. Values will be associated with the ‘XSD.integer` type.
A Resource property can reference this type as ‘Gearbox::Types::Integer`, `Integer`, or `XSD.integer`.
Class Method Summary collapse
Methods included from Gearbox::Type
Class Method Details
.serialize(value) ⇒ Object
22 23 24 |
# File 'lib/gearbox/types/decimal.rb', line 22 def self.serialize(value) RDF::Literal.new(value.is_a?(BigDecimal) ? value.to_s('F') : value.to_s, :datatype => XSD.decimal) end |
.unserialize(value) ⇒ Object
17 18 19 20 |
# File 'lib/gearbox/types/decimal.rb', line 17 def self.unserialize(value) object = value.object object.is_a?(BigDecimal) ? object : BigDecimal.new(object.to_s) end |