Class: RDF::Literal::Token
- Inherits:
-
RDF::Literal
- Object
- RDF::Literal
- RDF::Literal::Token
- Defined in:
- lib/rdf/model/literal/token.rb
Overview
A token literal.
Constant Summary collapse
- DATATYPE =
XSD.token
- GRAMMAR =
FIXME
/\A[^\x0D\x0A\x09]+\z/i.freeze
Constants inherited from RDF::Literal
Instance Attribute Summary
Attributes inherited from RDF::Literal
Instance Method Summary collapse
-
#canonicalize! ⇒ RDF::Literal
Converts this literal into its canonical lexical representation.
-
#initialize(value, options = {}) ⇒ Token
constructor
A new instance of Token.
-
#to_s ⇒ String
Returns the value as a string.
-
#to_sym ⇒ Symbol
Returns the value as a symbol.
Methods inherited from RDF::Literal
#==, #anonymous?, #canonicalize, #comperable_datatype?, datatyped_class, #eql?, #has_datatype?, #has_language?, #hash, #inspect, #invalid?, #literal?, new, #object, #plain?, #valid?, #validate!, #value
Methods included from Term
#<=>, #==, #constant?, #eql?, #variable?
Methods included from Value
#graph?, #inspect, #inspect!, #iri?, #literal?, #node?, #resource?, #statement?, #to_ntriples, #to_quad, #to_rdf, #type_error, #uri?, #variable?
Constructor Details
#initialize(value, options = {}) ⇒ Token
Returns a new instance of Token.
14 15 16 17 18 19 |
# File 'lib/rdf/model/literal/token.rb', line 14 def initialize(value, = {}) @datatype = RDF::URI([:datatype] || self.class.const_get(:DATATYPE)) @string = [:lexical] if .has_key?(:lexical) @string ||= value if value.is_a?(String) @object = value.is_a?(Symbol) ? value : value.to_s end |
Instance Method Details
#canonicalize! ⇒ RDF::Literal
Converts this literal into its canonical lexical representation.
26 27 28 29 |
# File 'lib/rdf/model/literal/token.rb', line 26 def canonicalize! @string = @object.to_s if @object self end |
#to_s ⇒ String
Returns the value as a string.
43 44 45 |
# File 'lib/rdf/model/literal/token.rb', line 43 def to_s @string || @object.to_s end |
#to_sym ⇒ Symbol
Returns the value as a symbol.
35 36 37 |
# File 'lib/rdf/model/literal/token.rb', line 35 def to_sym @object.to_sym end |