Class: Axiom::Relation::Operation::Sorted::DirectionSet

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

Overview

A class that represents a tuple sort order for a set of attributes

Instance Attribute Summary

Attributes inherited from Header

#keys, #to_ary

Instance Method Summary collapse

Methods inherited from Header

coerce, #context, #difference, #each, #empty?, #extend, #fetch, #initialize, #intersect, new, #project, #size, #union

Methods included from Aliasable

#inheritable_alias

Constructor Details

This class inherits a constructor from Axiom::Relation::Header

Instance Method Details

#attributesArray

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 each attribute in an Array

Returns:

  • (Array)


57
58
59
# File 'lib/axiom/relation/operation/sorted/direction_set.rb', line 57

def attributes
  map(&:attribute)
end

#rename(aliases) ⇒ DirectionSet

Rename the contained attributes with the provided aliases

Examples:

renamed = directions.rename(aliases)

Parameters:

Returns:



36
37
38
# File 'lib/axiom/relation/operation/sorted/direction_set.rb', line 36

def rename(aliases)
  new(map { |direction| direction.rename(aliases) })
end

#reverseDirectionSet

Reverse the directions for each attribute

Examples:

reversed = directions.reverse

Returns:



48
49
50
# File 'lib/axiom/relation/operation/sorted/direction_set.rb', line 48

def reverse
  new(map(&:reverse))
end

#sort_tuples(tuples) ⇒ Array

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.

Sort the supplied tuples in the correct direction

Parameters:

  • tuples (Array)

    the list of tuples to sort

Returns:

  • (Array)

    the sorted tuples



70
71
72
# File 'lib/axiom/relation/operation/sorted/direction_set.rb', line 70

def sort_tuples(tuples)
  tuples.to_a.sort { |left, right| cmp_tuples(left, right) }
end