Sha256: e6d038539f7dd8030038b558524e7dd29bb1371619e354613b01423090e37238

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 Bytes

Contents

module Spira::Types

  ##
  # A {Spira::Type} for Double values.  Values will be associated with the
  # `XSD.double` type.
  #
  # A {Spira::Resource} property can reference this type as
  # `Spira::Types::Double`, `Double`, or `XSD.double`.
  #
  # @see Spira::Type
  # @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
  class Double

    include Spira::Type

    def self.unserialize(value)
      value.object.to_f
    end

    def self.serialize(value)
      RDF::Literal.new(value.to_f, datatype: RDF::XSD.double)
    end

    register_alias RDF::XSD.double

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spira-3.3.0 lib/spira/types/double.rb