class RDF::Tabular::JSON

A JSON literal.

Constants

DATATYPE
GRAMMAR
dump_default_options

Public Class Methods

new(value, **options) click to toggle source

@param [Object] value @option options [String] :lexical (nil)

# File lib/rdf/tabular/literal.rb, line 16
def initialize(value, **options)
  @datatype = options[:datatype] || DATATYPE
  @string   = options[:lexical] if options.has_key?(:lexical)
  if value.is_a?(String)
    @string ||= value
  else
    @object = value
  end
end

Public Instance Methods

object() click to toggle source

Parse value, if necessary

@return [Object]

# File lib/rdf/tabular/literal.rb, line 30
def object
  @object ||= ::JSON.parse(value)
end
to_s() click to toggle source
# File lib/rdf/tabular/literal.rb, line 34
def to_s
  @string ||= value.to_json
end