Class: Neo4j::Core::Cypher::MatchNode

Inherits:
Match show all
Defined in:
lib/neo4j-core/cypher/cypher.rb

Instance Attribute Summary collapse

Attributes inherited from Match

#algorithm, #dir, #expressions, #left, #next, #prev, #right, #var_name

Attributes included from Variable

#return_method

Attributes inherited from Expression

#clause, #expressions, #separator

Instance Method Summary collapse

Methods inherited from Match

#find_match_start, #left_var_name, #length, #nodes, #referenced!, #referenced?, #rels, #right_expr, #right_var_name, #to_s

Methods included from Variable

#[], #as, #distinct, #exist?, #is_a?, #neo_id, #property?

Methods inherited from Expression

#insert_last, #prefix, #prefixes, #valid?

Constructor Details

#initialize(left, right, expressions, dir) ⇒ MatchNode

Returns a new instance of MatchNode.



641
642
643
644
645
646
647
648
649
650
651
# File 'lib/neo4j-core/cypher/cypher.rb', line 641

def initialize(left, right, expressions, dir)
  dir_op = case dir
             when :outgoing then
               "-->"
             when :incoming then
               "<--"
             when :both then
               "--"
           end
  super(left, right, expressions, dir, dir_op)
end

Instance Attribute Details

#dir_opObject (readonly)

Returns the value of attribute dir_op.



639
640
641
# File 'lib/neo4j-core/cypher/cypher.rb', line 639

def dir_op
  @dir_op
end

Instance Method Details

#-(other) ⇒ MatchRelRight

Returns the right part of an relationship cypher query.

Returns:

  • (MatchRelRight)

    the right part of an relationship cypher query.

See Also:



690
691
692
693
# File 'lib/neo4j-core/cypher/cypher.rb', line 690

def -(other)
  expressions.delete(self)
  self.next = MatchRelLeft.new(self, other, expressions, :both)
end

#<(other) ⇒ MatchRelRight

Returns the right part of an relationship cypher query.

Returns:

  • (MatchRelRight)

    the right part of an relationship cypher query.

See Also:



683
684
685
686
# File 'lib/neo4j-core/cypher/cypher.rb', line 683

def <(other)
  expressions.delete(self)
  self.next = MatchRelLeft.new(self, other, expressions, :incoming)
end

#<<(other) ⇒ Object



664
665
666
667
# File 'lib/neo4j-core/cypher/cypher.rb', line 664

def <<(other)
  expressions.delete(self)
  self.next = MatchNode.new(self, other, expressions, :incoming)
end

#>(other) ⇒ MatchRelRight

Returns the right part of an relationship cypher query.

Parameters:

  • other (Symbol, NodeVar, String)

    part of the match cypher statement.

Returns:

  • (MatchRelRight)

    the right part of an relationship cypher query.



676
677
678
679
# File 'lib/neo4j-core/cypher/cypher.rb', line 676

def >(other)
  expressions.delete(self)
  self.next = MatchRelLeft.new(self, other, expressions, :outgoing)
end

#>>(other) ⇒ Object



669
670
671
672
# File 'lib/neo4j-core/cypher/cypher.rb', line 669

def >>(other)
  expressions.delete(self)
  self.next = MatchNode.new(self, other, expressions, :outgoing)
end

#exprString

Returns a cypher string for this match.

Returns:

  • (String)

    a cypher string for this match.



654
655
656
657
658
659
660
661
662
# File 'lib/neo4j-core/cypher/cypher.rb', line 654

def expr
  if prev
    # we have chained more then one relationships in a match expression
    "#{dir_op}(#{right_expr})"
  else
    # the right is an relationship and could be an expressions, e.g "r?"
    "(#{left_var_name})#{dir_op}(#{right_expr})"
  end
end