Class: RDF::Tabular::JSON
- Inherits:
-
Literal
- Object
- Literal
- RDF::Tabular::JSON
- Defined in:
- lib/rdf/tabular/literal.rb
Overview
A JSON literal.
Constant Summary collapse
Instance Method Summary collapse
-
#initialize(value, **options) ⇒ JSON
constructor
A new instance of JSON.
-
#object ⇒ Object
Parse value, if necessary.
- #to_s ⇒ Object
Constructor Details
#initialize(value, **options) ⇒ JSON
Returns a new instance of JSON.
16 17 18 19 20 21 22 23 24 |
# File 'lib/rdf/tabular/literal.rb', line 16 def initialize(value, **) @datatype = [:datatype] || DATATYPE @string = [:lexical] if .has_key?(:lexical) if value.is_a?(String) @string ||= value else @object = value end end |
Instance Method Details
#object ⇒ Object
Parse value, if necessary
30 31 32 |
# File 'lib/rdf/tabular/literal.rb', line 30 def object @object ||= ::JSON.parse(value) end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/rdf/tabular/literal.rb', line 34 def to_s @string ||= value.to_json end |