Sha256: 6ac918838babdd6760a6ae42653240746111c45717e9a165a0ae20f2ef82a56f
Contents?: true
Size: 725 Bytes
Versions: 1
Compression:
Stored size: 725 Bytes
Contents
require 'bigdecimal' module Spira::Types ## # A {Spira::Type} for integer values. Values will be associated with the # `XSD.integer` type. # # A {Spira::Resource} property can reference this type as # `Spira::Types::Integer`, `Integer`, or `XSD.integer`. # # @see Spira::Type # @see https://ruby-rdf.github.io/rdf/RDF/Literal.html class Decimal include Spira::Type def self.unserialize(value) object = value.object object.is_a?(BigDecimal) ? object : BigDecimal.new(object.to_s) end def self.serialize(value) RDF::Literal.new(value.is_a?(BigDecimal) ? value.to_s('F') : value.to_s, datatype: RDF::XSD.decimal) end register_alias RDF::XSD.decimal end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spira-3.3.0 | lib/spira/types/decimal.rb |