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
- DATATYPE =
XSD.token
- GRAMMAR =
FIXME
/\A[^\x0D\x0A\x09]+\z/i.freeze
Constants inherited from RDF::Literal
Instance Method Summary (collapse)
-
- (RDF::Literal) canonicalize!
Converts this literal into its canonical lexical representation.
-
- (Token) initialize(value, options = {})
constructor
A new instance of Token.
-
- (String) to_s
Returns the value as a string.
-
- (Symbol) to_sym
Returns the value as a symbol.
Methods inherited from RDF::Literal
#==, #anonymous?, #canonicalize, #eql?, #has_datatype?, #has_language?, #hash, #inspect, #invalid?, #literal?, #object, #valid?, #validate!, #value
Methods included from Term
Methods included from Value
#graph?, #inspect, #inspect!, #iri?, #literal?, #node?, #resource?, #statement?, #to_ntriples, #to_rdf, #uri?, #variable?
Constructor Details
- (Token) initialize(value, options = {})
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] || DATATYPE) @string = [:lexical] if .has_key?(:lexical) @string = value if !defined?(@string) && value.is_a?(String) @object = value.is_a?(Symbol) ? value : value.to_s end |
Instance Method Details
- (RDF::Literal) canonicalize!
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 |
- (String) to_s
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 |
- (Symbol) to_sym
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 |