Sha256: 721ce6f2b8c401ddd74dfe644a41832e994a33d0f2cf7db08ed2552164c7fe9a
Contents?: true
Size: 915 Bytes
Versions: 1
Compression:
Stored size: 915 Bytes
Contents
require 'active_rdf' # Represents an RDF literal, optionally datatyped. # TODO: language tags class Literal Namespace.register :xsd, 'http://www.w3.org/2001/XMLSchema#' attr_reader :value, :type @value, @type = nil, nil # Constructs literal with given datatype. If no datatype is given, automatic # conversion from Ruby to XSD datatype is tried. def initialize(value, type=nil) @value = value @type = type if @type.nil? @type = case value when String XSD::string when Date, Time, DateTime XSD::date when TrueClass, FalseClass XSD::boolean when Fixnum XSD::integer end end end # returns string serialisation of literal, e.g. "test"^^xsd:string def to_s if type "\"#{value}\"^^#{type.to_s}" else "\"value\"" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerdf-1.3 | lib/active_rdf/objectmanager/literal.rb |