Sha256: 98e927ba17b431c3368e92d8196daa26b2298c16c3f945b8aa6a08cb5494e13f

Contents?: true

Size: 696 Bytes

Versions: 12

Compression:

Stored size: 696 Bytes

Contents

module Spira::Types

  ##
  # A {Spira::Type} for Boolean values.  Values will be expressed as booleans
  # and packaged as `XSD.boolean` `RDF::Literal`s.
  #
  # A {Spira::Resource} property can reference this type as
  # `Spira::Types::Boolean`, `Boolean`, or `XSD.boolean`.
  #
  # @see Spira::Type
  # @see http://rdf.rubyforge.org/RDF/Literal.html
  class Boolean

    include Spira::Type

    def self.unserialize(value)
      value.object == true
    end

    def self.serialize(value)
      if value
        RDF::Literal.new(true, :datatype => XSD.boolean)
      else 
        RDF::Literal.new(false, :datatype => XSD.boolean)
      end
    end

    register_alias XSD.boolean

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spira-0.0.12 lib/spira/types/boolean.rb
spira-0.0.11 lib/spira/types/boolean.rb
spira-0.0.10 lib/spira/types/boolean.rb
spira-0.0.9 lib/spira/types/boolean.rb
spira-0.0.8 lib/spira/types/boolean.rb
spira-0.0.7 lib/spira/types/boolean.rb
spira-0.0.6 lib/spira/types/boolean.rb
spira-0.0.5 lib/spira/types/boolean.rb
spira-0.0.4 lib/spira/types/boolean.rb
spira-0.0.3 lib/spira/types/boolean.rb
spira-0.0.2 lib/spira/types/boolean.rb
spira-0.0.1 lib/spira/types/boolean.rb