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