class RDF::AllegroGraph::Query::PrologLiteral

A literal value which can be passed as an argument to a Prolog functor.

@see @FunctorExpression

Public Class Methods

new(value) click to toggle source

Constract a new Prolog literal.

@param [Object] value A Ruby value.

# File lib/rdf/allegro_graph/query/prolog_literal.rb, line 9
def initialize(value)
  @value = value
end

Public Instance Methods

to_s() click to toggle source

Serialize this literal as a string. We need to be careful about security here: Our callers might try to pass in untrustworthy values without thinking through the consequences, and we want to limit the damage. We assume that all symbols are trustworthy.

@return [String]

# File lib/rdf/allegro_graph/query/prolog_literal.rb, line 19
def to_s
  case @value
  when Symbol, Numeric
    @value.to_s
  else
    err = "Don't know how to serialize #{@value.inspect} securely"
    raise ArgumentError.new(err)
  end
end