Class: Sequel::SQL::OrderedExpression
- Inherits:
-
Expression
- Object
- Expression
- Sequel::SQL::OrderedExpression
- Defined in:
- lib/sequel/sql.rb
Overview
Represents a column/expression to order the result set by.
Instance Attribute Summary collapse
-
#descending ⇒ Object
readonly
Whether the expression should order the result set in a descending manner.
-
#expression ⇒ Object
readonly
The expression to order the result set by.
Instance Method Summary collapse
-
#asc ⇒ Object
Return a copy that is ASC.
-
#desc ⇒ Object
Return a copy that is DESC.
-
#initialize(expression, descending = true) ⇒ OrderedExpression
constructor
Set the expression and descending attributes to the given values.
-
#invert ⇒ Object
Return an inverted expression, changing ASC to DESC and vice versa.
Methods inherited from Expression
Constructor Details
#initialize(expression, descending = true) ⇒ OrderedExpression
Set the expression and descending attributes to the given values.
734 735 736 |
# File 'lib/sequel/sql.rb', line 734 def initialize(expression, descending = true) @expression, @descending = expression, descending end |
Instance Attribute Details
#descending ⇒ Object (readonly)
Whether the expression should order the result set in a descending manner
731 732 733 |
# File 'lib/sequel/sql.rb', line 731 def descending @descending end |
#expression ⇒ Object (readonly)
The expression to order the result set by.
728 729 730 |
# File 'lib/sequel/sql.rb', line 728 def expression @expression end |
Instance Method Details
#asc ⇒ Object
Return a copy that is ASC
739 740 741 |
# File 'lib/sequel/sql.rb', line 739 def asc OrderedExpression.new(@expression, false) end |
#desc ⇒ Object
Return a copy that is DESC
744 745 746 |
# File 'lib/sequel/sql.rb', line 744 def desc OrderedExpression.new(@expression) end |
#invert ⇒ Object
Return an inverted expression, changing ASC to DESC and vice versa
749 750 751 |
# File 'lib/sequel/sql.rb', line 749 def invert OrderedExpression.new(@expression, !@descending) end |