Class: SQLTree::Node::Ordering
- Defined in:
- lib/sql_tree/node/ordering.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#expression ⇒ Object
Returns the value of attribute expression.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(expression, direction = nil) ⇒ Ordering
constructor
A new instance of Ordering.
- #to_sql ⇒ Object
Methods inherited from Base
[], #inspect, #quote_str, #quote_var
Constructor Details
#initialize(expression, direction = nil) ⇒ Ordering
Returns a new instance of Ordering.
7 8 9 |
# File 'lib/sql_tree/node/ordering.rb', line 7 def initialize(expression, direction = nil) @expression, @direction = expression, direction end |
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction.
5 6 7 |
# File 'lib/sql_tree/node/ordering.rb', line 5 def direction @direction end |
#expression ⇒ Object
Returns the value of attribute expression.
5 6 7 |
# File 'lib/sql_tree/node/ordering.rb', line 5 def expression @expression end |
Class Method Details
.parse(tokens) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/sql_tree/node/ordering.rb', line 17 def self.parse(tokens) ordering = self.new(SQLTree::Node::Expression.parse(tokens)) if tokens.peek && tokens.peek.direction? ordering.direction = tokens.next.literal.downcase.to_sym end return ordering end |
Instance Method Details
#to_sql ⇒ Object
11 12 13 14 15 |
# File 'lib/sql_tree/node/ordering.rb', line 11 def to_sql sql = expression.to_sql sql << " #{direction.to_s.upcase}" if direction sql end |