Class: Neo4j::Cypher::Property

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

Overview

A property is returned from a Variable by using the [] operator.

It has a number of useful method like count, sum, avg, min, max, collect, head, last, tail,

Examples:

n=node(2, 3, 4); n[:name].collect
# same as START n0=node(2,3,4) RETURN collect(n0.property)

Defined Under Namespace

Classes: EvalContext

Constant Summary

Constants included from Clause

Clause::NAME, Clause::ORDER

Instance Attribute Summary collapse

Attributes included from Clause

#clause_list, #clause_type, #eval_context, #insert_order

Instance Method Summary collapse

Methods included from Clause

#<=>, #alias_name, #as_alias, #as_alias?, #clause_position, #create_clause_args_for, #match_value=, #prefix, #referenced!, #referenced?, #separator, #to_prop_string, #valid_clause?, #var_name=

Constructor Details

#initialize(var, prop_name = nil) ⇒ Property

Returns a new instance of Property.



17
18
19
20
21
# File 'lib/neo4j-cypher/property.rb', line 17

def initialize(var, prop_name = nil)
  super(var.clause_list, :property, EvalContext)
  @var = var
  @prop_name = prop_name
end

Instance Attribute Details

#prop_nameObject

Returns the value of attribute prop_name.



15
16
17
# File 'lib/neo4j-cypher/property.rb', line 15

def prop_name
  @prop_name
end

Instance Method Details

#exprObject



28
29
30
31
32
33
34
# File 'lib/neo4j-cypher/property.rb', line 28

def expr
  if @function
    "#{@prop_name}(#{var_name})"
  else
    @prop_name ? "#{@var.var_name}.#{@prop_name}" : @var.var_name.to_s
  end
end

#match_valueObject



48
49
50
# File 'lib/neo4j-cypher/property.rb', line 48

def match_value
  @var.match_value
end

#return_valueObject



43
44
45
# File 'lib/neo4j-cypher/property.rb', line 43

def return_value
  to_cypher
end

#to_cypherObject



58
59
60
# File 'lib/neo4j-cypher/property.rb', line 58

def to_cypher
  expr
end

#to_function!(prop_name = nil) ⇒ Object



37
38
39
40
41
# File 'lib/neo4j-cypher/property.rb', line 37

def to_function!(prop_name = nil)
  @prop_name = prop_name if prop_name
  @function = true
  eval_context
end

#unary_operator(op, clause_type = :where, post_fix = nil) ⇒ Object



52
53
54
55
# File 'lib/neo4j-cypher/property.rb', line 52

def unary_operator(op, clause_type = :where, post_fix = nil)
  # TODO DELETE THIS ?
  Operator.new(clause_list, self, nil, op, clause_type, post_fix).unary!
end

#var_nameObject

TODO check why needed



24
25
26
# File 'lib/neo4j-cypher/property.rb', line 24

def var_name
  @var.var_name
end