Class: Sequel::SQL::OrderedExpression

Inherits:
Expression show all
Defined in:
lib/sequel/lib/sequel/sql.rb

Overview

Represents a column/expression to order the result set by.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#lit

Constructor Details

#initialize(expression, descending = true) ⇒ OrderedExpression

Set the expression and descending attributes to the given values.


691
692
693
# File 'lib/sequel/lib/sequel/sql.rb', line 691

def initialize(expression, descending = true)
  @expression, @descending = expression, descending
end

Instance Attribute Details

#descendingObject (readonly)

Whether the expression should order the result set in a descending manner


688
689
690
# File 'lib/sequel/lib/sequel/sql.rb', line 688

def descending
  @descending
end

#expressionObject (readonly)

The expression to order the result set by.


685
686
687
# File 'lib/sequel/lib/sequel/sql.rb', line 685

def expression
  @expression
end

Instance Method Details

#ascObject

Return a copy that is ASC


696
697
698
# File 'lib/sequel/lib/sequel/sql.rb', line 696

def asc
  OrderedExpression.new(@expression, false)
end

#descObject

Return a copy that is DESC


701
702
703
# File 'lib/sequel/lib/sequel/sql.rb', line 701

def desc
  OrderedExpression.new(@expression)
end

#invertObject

Return an inverted expression, changing ASC to DESC and vice versa


706
707
708
# File 'lib/sequel/lib/sequel/sql.rb', line 706

def invert
  OrderedExpression.new(@expression, !@descending)
end