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
attr_reader, comparison_attrs, #eql?, #lit, #sql_literal
Constructor Details
#initialize(expression, descending = true) ⇒ OrderedExpression
Set the expression and descending attributes to the given values.
761 762 763 |
# File 'lib/sequel/sql.rb', line 761 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
758 759 760 |
# File 'lib/sequel/sql.rb', line 758 def descending @descending end |
#expression ⇒ Object (readonly)
The expression to order the result set by.
755 756 757 |
# File 'lib/sequel/sql.rb', line 755 def expression @expression end |
Instance Method Details
#asc ⇒ Object
Return a copy that is ASC
766 767 768 |
# File 'lib/sequel/sql.rb', line 766 def asc OrderedExpression.new(@expression, false) end |
#desc ⇒ Object
Return a copy that is DESC
771 772 773 |
# File 'lib/sequel/sql.rb', line 771 def desc OrderedExpression.new(@expression) end |
#invert ⇒ Object
Return an inverted expression, changing ASC to DESC and vice versa
776 777 778 |
# File 'lib/sequel/sql.rb', line 776 def invert OrderedExpression.new(@expression, !@descending) end |