Class: RDF::Literal::XML
- Inherits:
-
RDF::Literal
- Object
- RDF::Literal
- RDF::Literal::XML
- Defined in:
- lib/rdf/rdfxml/patches/literal_hacks.rb
Overview
An XML literal.
Instance Method Summary collapse
-
#canonicalize ⇒ Literal
Converts the literal into its canonical lexical representation.
-
#initialize(value, options = {}) ⇒ XML
constructor
A new instance of XML.
-
#to_s ⇒ String
Returns the value as a string.
Constructor Details
#initialize(value, options = {}) ⇒ XML
Returns a new instance of XML.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rdf/rdfxml/patches/literal_hacks.rb', line 26 def initialize(value, = {}) [:namespaces] ||= {} @library = case [:library] when nil case when defined?(::Nokogiri) then :nokogiri when defined?(::LibXML) then :libxml else :rexml end when :nokogiri, :libxml, :rexml [:library] else raise ArgumentError.new("expected :rexml, :libxml or :nokogiri, but got #{[:library].inspect}") end @datatype = [:datatype] || DATATYPE @string = [:lexical] if .has_key?(:lexical) @object = parse_value(value, ) @string = serialize_nodeset(@object) end |
Instance Method Details
#canonicalize ⇒ Literal
Converts the literal into its canonical lexical representation.
53 54 55 56 |
# File 'lib/rdf/rdfxml/patches/literal_hacks.rb', line 53 def canonicalize # This is the opportunity to use exclusive canonicalization library self end |
#to_s ⇒ String
Returns the value as a string.
62 63 64 |
# File 'lib/rdf/rdfxml/patches/literal_hacks.rb', line 62 def to_s @string end |