Class: Neo4j::Cypher::Operand

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j-cypher/operator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Operand

Returns a new instance of Operand.



7
8
9
# File 'lib/neo4j-cypher/operator.rb', line 7

def initialize(obj)
  @obj = obj.respond_to?(:clause) ? obj.clause : obj
end

Instance Attribute Details

#objObject (readonly)

Returns the value of attribute obj.



5
6
7
# File 'lib/neo4j-cypher/operator.rb', line 5

def obj
  @obj
end

Instance Method Details

#regexp?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/neo4j-cypher/operator.rb', line 11

def regexp?
  @obj.kind_of?(Regexp)
end

#to_sObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/neo4j-cypher/operator.rb', line 15

def to_s
  if @obj.is_a?(String)
    %Q["#{@obj}"]
  elsif @obj.is_a?(Operator)
    "(#{@obj.to_s})"
  elsif @obj.is_a?(MatchStart)
    "(#{@obj.to_cypher})"
  elsif @obj.respond_to?(:expr) && @obj.expr
    @obj.expr
  elsif @obj.respond_to?(:source)
    "'#{@obj.source}'"
  elsif @obj.respond_to?(:return_value)
    @obj.return_value.to_s
  else
    @obj.to_s
  end
end