Class: Neo4j::Core::Cypher::Expression

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

Direct Known Subclasses

ExprOp, Limit, Match, OrderBy, Predicate, Return, Skip, Start, Where

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expressions, clause) ⇒ Expression

Returns a new instance of Expression.



238
239
240
241
242
243
# File 'lib/neo4j-core/cypher/cypher.rb', line 238

def initialize(expressions, clause)
  @clause = clause
  @expressions = expressions
  insert_last(clause)
  @separator = ","
end

Instance Attribute Details

#clauseObject

Returns the value of attribute clause.



236
237
238
# File 'lib/neo4j-core/cypher/cypher.rb', line 236

def clause
  @clause
end

#expressionsObject (readonly)

Returns the value of attribute expressions.



235
236
237
# File 'lib/neo4j-core/cypher/cypher.rb', line 235

def expressions
  @expressions
end

#separatorObject

Returns the value of attribute separator.



236
237
238
# File 'lib/neo4j-core/cypher/cypher.rb', line 236

def separator
  @separator
end

Instance Method Details

#insert_last(clause) ⇒ Object



245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/neo4j-core/cypher/cypher.rb', line 245

def insert_last(clause)
  curr_clause = clause
  while (i = @expressions.reverse.index { |e| e.clause == curr_clause }).nil? && curr_clause != :start
    curr_clause = prev_clause(curr_clause)
  end

  if i.nil?
    @expressions << self
  else
    pos = @expressions.size - i
    @expressions.insert(pos, self)
  end
end

#prefixObject



267
268
269
# File 'lib/neo4j-core/cypher/cypher.rb', line 267

def prefix
  prefixes[clause]
end

#prefixesObject



263
264
265
# File 'lib/neo4j-core/cypher/cypher.rb', line 263

def prefixes
  {:start => "START", :where => " WHERE", :match => " MATCH", :return => " RETURN", :order_by => " ORDER BY", :skip => " SKIP", :limit => " LIMIT"}
end

#prev_clause(clause) ⇒ Object



259
260
261
# File 'lib/neo4j-core/cypher/cypher.rb', line 259

def prev_clause(clause)
  {:limit => :skip, :skip => :order_by, :order_by => :return, :return => :where, :where => :match, :match => :start}[clause]
end

#valid?Boolean

Returns:

  • (Boolean)


271
272
273
# File 'lib/neo4j-core/cypher/cypher.rb', line 271

def valid?
  true
end