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?, #one, #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
70 71 72 73 |
# File 'lib/axiom/relation/operation/order.rb', line 70 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 |
# File 'lib/axiom/relation/operation/order.rb', line 32 def self.new(operand, directions) directions = DirectionSet.coerce(directions) assert_order_by_full_header(operand, directions) super end |
Instance Method Details
#delete(other) ⇒ Order
Delete a relation from the Order
120 121 122 123 |
# File 'lib/axiom/relation/operation/order.rb', line 120 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
89 90 91 92 93 |
# File 'lib/axiom/relation/operation/order.rb', line 89 def each return to_enum unless block_given? directions.sort_tuples(operand).each { |tuple| yield tuple } self end |