Class: Neo4j::Cypher::OrderBy

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

Constant Summary

Constants included from Clause

Clause::NAME, Clause::ORDER

Instance Attribute Summary

Attributes included from Clause

#clause_list, #clause_type, #eval_context, #expr, #insert_order

Instance Method Summary collapse

Methods included from Clause

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

Constructor Details

#initialize(clause_list, context) ⇒ OrderBy

Returns a new instance of OrderBy.



36
37
38
39
# File 'lib/neo4j-cypher/return.rb', line 36

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

Instance Method Details

#asc(props) ⇒ Object



41
42
43
# File 'lib/neo4j-cypher/return.rb', line 41

def asc(props)
  @orders << [:asc, props.map(&:clause)]
end

#desc(props) ⇒ Object



45
46
47
# File 'lib/neo4j-cypher/return.rb', line 45

def desc(props)
  @orders << [:desc, props.map(&:clause)]
end

#to_cypherObject



49
50
51
52
53
54
55
56
57
# File 'lib/neo4j-cypher/return.rb', line 49

def to_cypher
  @orders.map do |pair|
    if pair[0] == :asc
      pair[1].map{|p| p.alias_name || p.return_value}.join(', ')
    else
      pair[1].map{|p| p.alias_name || p.return_value}.join(', ') + " DESC"
    end
  end.join(', ')
end