Class: Neo4j::Core::Cypher::OrderBy

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

Instance Attribute Summary

Attributes inherited from Expression

#clause, #expressions, #separator

Instance Method Summary collapse

Methods inherited from Expression

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

Constructor Details

#initialize(expressions) ⇒ OrderBy

Returns a new instance of OrderBy.



458
459
460
461
# File 'lib/neo4j-core/cypher/cypher.rb', line 458

def initialize(expressions)
  super(expressions, :order_by)
  @orders = []
end

Instance Method Details

#asc(props) ⇒ Object



463
464
465
# File 'lib/neo4j-core/cypher/cypher.rb', line 463

def asc(props)
  @orders << [:asc, props]
end

#desc(props) ⇒ Object



467
468
469
# File 'lib/neo4j-core/cypher/cypher.rb', line 467

def desc(props)
  @orders << [:desc, props]
end

#to_sObject



471
472
473
474
475
476
477
478
479
# File 'lib/neo4j-core/cypher/cypher.rb', line 471

def to_s
  @orders.map do |pair|
    if pair[0] == :asc
      pair[1].map(&:var_name).join(', ')
    else
      pair[1].map(&:var_name).join(', ') + " DESC"
    end
  end.join(', ')
end