Class: Axiom::Relation::Operation::Order
- Inherits:
-
Axiom::Relation
- Object
- Axiom::Relation
- Axiom::Relation::Operation::Order
- Includes:
- Unary
- Defined in:
- lib/axiom/relation/operation/order.rb,
lib/axiom/relation/operation/order/direction.rb,
lib/axiom/relation/operation/order/direction_set.rb
Overview
A class representing a sorted relation
Direct Known Subclasses
Defined Under Namespace
Modules: Methods Classes: Ascending, Descending, Direction, DirectionSet
Instance Attribute Summary collapse
-
#directions ⇒ Operation::Order::DirectionSet
readonly
private
The relation sort order.
Attributes included from Operation::Unary
Attributes inherited from Axiom::Relation
Class Method Summary collapse
-
.new(operand, directions) ⇒ Order
Instantiate a new Order.
Instance Method Summary collapse
-
#delete(other) ⇒ Order
Delete a relation from the Order.
-
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set.
-
#initialize(operand, directions) ⇒ undefined
constructor
private
Initialize an Order.
-
#insert(other) ⇒ Order
Insert a relation into the Order.
Methods inherited from Axiom::Relation
#==, #[], #empty?, #include?, #materialize, #materialized?, #replace
Methods included from Visitable
Constructor Details
#initialize(operand, directions) ⇒ undefined
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.
Initialize an Order
51 52 53 54 |
# File 'lib/axiom/relation/operation/order.rb', line 51 def initialize(operand, directions) super(operand) @directions = directions end |
Instance Attribute Details
#directions ⇒ Operation::Order::DirectionSet (readonly)
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.
The relation sort order
17 18 19 |
# File 'lib/axiom/relation/operation/order.rb', line 17 def directions @directions end |
Class Method Details
.new(operand, directions) ⇒ Order
Instantiate a new Order
32 33 34 35 36 37 38 39 |
# File 'lib/axiom/relation/operation/order.rb', line 32 def self.new(operand, directions) header = operand.header directions = DirectionSet.coerce(directions) do |direction| header[direction] unless direction.kind_of?(Direction) end directions |= header - directions.attributes super end |
Instance Method Details
#delete(other) ⇒ Order
Delete a relation from the Order
101 102 103 104 |
# File 'lib/axiom/relation/operation/order.rb', line 101 def delete(other) assert_matching_directions(other, DELETED) operand.delete(other.operand).sort_by(directions) end |
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set
70 71 72 73 74 |
# File 'lib/axiom/relation/operation/order.rb', line 70 def each return to_enum unless block_given? directions.sort_tuples(operand).each { |tuple| yield tuple } self end |