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, datatype: nil, lexical: nil, **options)
click to toggle source
@param [String, Symbol, to_sym
] value @param (see Literal#initialize)
# File lib/rdf/model/literal/token.rb, line 14 def initialize(value, datatype: nil, lexical: nil, **options) @datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE)) @string = lexical || (value if value.is_a?(String)) @object = value.is_a?(Symbol) ? value : value.to_sym 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 25 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 42 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 34 def to_sym @object.to_sym end