Class: Axiom::Relation::Operation::Sorted::Ascending

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

Overview

Represent an attribute sorted ascending

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 before the right

  • (0)

    returned if the left and right are equal

  • (1)

    returned if the left should be sorted after the right



141
142
143
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 141

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

.reverseClass<Descending>

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:



122
123
124
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 122

def self.reverse
  Descending
end