Method: RDF::Query::Variable#to_s

Defined in:
lib/rdf/query/variable.rb

#to_sString Also known as: to_base

Returns a string representation of this variable.

Distinguished variables are indicated with a single ‘?`.

Non-distinguished variables are indicated with a double ‘??`

Existential variables are indicated using a single ‘$`, or with `$$` if also non-distinguished

Examples:

v = Variable.new("a")
v.to_s => '?a'
v.distinguished = false
v.to_s => '??a'

Returns:

  • (String)

Since:

  • 0.3.0



290
291
292
293
# File 'lib/rdf/query/variable.rb', line 290

def to_s
  prefix = distinguished? ? (existential? ? '$' : '?') : (existential? ? '$$' : '??')
  unbound? ? "#{prefix}#{name}" : "#{prefix}#{name}=#{value}"
end