Class: Neo4j::Core::Cypher::RelVar

Inherits:
Object
  • Object
show all
Includes:
Variable
Defined in:
lib/neo4j-core/cypher/cypher.rb

Overview

represent an unbound relationship variable used in match,where,return statement

Instance Attribute Summary collapse

Attributes included from Variable

#return_method

Instance Method Summary collapse

Methods included from Variable

#as, #count, #distinct, #exist?, #is_a?, #neo_id, #property?

Constructor Details

#initialize(expressions, variables, expr) ⇒ RelVar

Returns a new instance of RelVar.



839
840
841
842
843
844
845
846
# File 'lib/neo4j-core/cypher/cypher.rb', line 839

def initialize(expressions, variables, expr)
  variables << self
  @expr = expr
  @expressions = expressions
  guess = expr ? /([[:alpha:]_]*)/.match(expr)[1] : ""
  @auto_var_name = "v#{variables.size}"
  @var_name = guess.empty? ? @auto_var_name : guess
end

Instance Attribute Details

#exprObject (readonly)

Returns the value of attribute expr.



837
838
839
# File 'lib/neo4j-core/cypher/cypher.rb', line 837

def expr
  @expr
end

#expressionsObject (readonly)

Returns the value of attribute expressions.



837
838
839
# File 'lib/neo4j-core/cypher/cypher.rb', line 837

def expressions
  @expressions
end

#var_nameObject (readonly)

Returns the value of attribute var_name.



837
838
839
# File 'lib/neo4j-core/cypher/cypher.rb', line 837

def var_name
  @var_name
end

Instance Method Details

#[](p) ⇒ Object



852
853
854
855
856
857
858
# File 'lib/neo4j-core/cypher/cypher.rb', line 852

def [](p)
  if @expr.to_s[0..0] == ':'
    @var_name = @auto_var_name
    @expr = "#{@var_name}#{@expr}"
  end
  super
end

#rel_typeObject



848
849
850
# File 'lib/neo4j-core/cypher/cypher.rb', line 848

def rel_type
  Property.new(@expressions, self, 'type').to_function!
end

#to_sString

Returns a cypher string for this relationship variable.

Returns:

  • (String)

    a cypher string for this relationship variable



861
862
863
# File 'lib/neo4j-core/cypher/cypher.rb', line 861

def to_s
  var_name
end