Class: Axiom::Relation::Operation::Sorted::Descending

Inherits:
Direction
  • Object
show all
Defined in:
lib/axiom/relation/operation/sorted/direction.rb

Overview

Represent an attribute sorted descending

Instance Attribute Summary

Attributes inherited from Direction

#attribute

Class Method Summary collapse

Methods inherited from Direction

#call, coerce, #initialize, #name, #rename, #reverse

Methods included from Aliasable

#inheritable_alias

Constructor Details

This class inherits a constructor from Axiom::Relation::Operation::Sorted::Direction

Class Method Details

.call(left, right) ⇒ -1, ...

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Compare the left and right value

Parameters:

  • left (Comparable)
  • right (Comparable)

Returns:

  • (-1)

    returned if the left should be sorted after the right

  • (0)

    returned if the right and left are equal

  • (1)

    returned if the left should be sorted before the right



174
175
176
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 174

def self.call(left, right)
  right <=> left || (1 if right.nil?) || (-1 if left.nil?)
end

.reverseClass<Ascending>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the reversed direction class

Returns:



155
156
157
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 155

def self.reverse
  Ascending
end