class RDF::Literal::Token

A token literal.

@see www.w3.org/TR/xmlschema11-2/#token @since 0.2.3

Constants

DATATYPE
GRAMMAR

Public Class Methods

new(value, options = {}) click to toggle source

@param [Symbol, to_s] value @option options [String] :lexical (nil)

# File lib/rdf/model/literal/token.rb, line 14
def initialize(value, options = {})
  @datatype = RDF::URI(options[:datatype] || self.class.const_get(:DATATYPE))
  @string   = options[:lexical] if options.has_key?(:lexical)
  @string   ||= value if value.is_a?(String)
  @object   = value.is_a?(Symbol) ? value : value.to_s
end

Public Instance Methods

canonicalize!() click to toggle source

Converts this literal into its canonical lexical representation.

@return [RDF::Literal] `self` @see www.w3.org/TR/xmlschema11-2/#boolean

# File lib/rdf/model/literal/token.rb, line 26
def canonicalize!
  @string = @object.to_s if @object
  self
end
to_s() click to toggle source

Returns the value as a string.

@return [String]

# File lib/rdf/model/literal/token.rb, line 43
def to_s
  @string || @object.to_s
end
to_sym() click to toggle source

Returns the value as a symbol.

@return [Symbol]

# File lib/rdf/model/literal/token.rb, line 35
def to_sym
  @object.to_sym
end