Class: Axiom::Relation::Operation::Limit
- Inherits:
-
Axiom::Relation
- Object
- Axiom::Relation
- Axiom::Relation::Operation::Limit
- Includes:
- Unary
- Defined in:
- lib/axiom/relation/operation/limit.rb
Overview
A class representing a limited relation
Defined Under Namespace
Modules: Methods
Instance Attribute Summary collapse
-
#directions ⇒ Operation::Sorted::DirectionSet
readonly
private
The relation sort order.
-
#limit ⇒ Integer
readonly
Return the limit.
Attributes included from Operation::Unary
Attributes inherited from Axiom::Relation
Class Method Summary collapse
-
.new(operand, limit) ⇒ Limit
Instantiate a new Limit.
Instance Method Summary collapse
-
#delete ⇒ undefined
Raise an exception when deleting from the Limit.
-
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set.
-
#initialize(operand, limit) ⇒ undefined
constructor
private
Initialize a Limit.
-
#insert ⇒ undefined
Raise an exception when inserting into the Limit.
Methods inherited from Axiom::Relation
#==, #[], #empty?, #include?, #materialize, #materialized?, #replace
Methods included from Visitable
Constructor Details
#initialize(operand, limit) ⇒ 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 a Limit
92 93 94 95 96 |
# File 'lib/axiom/relation/operation/limit.rb', line 92 def initialize(operand, limit) super(operand) @limit = limit @directions = operand.directions end |
Instance Attribute Details
#directions ⇒ Operation::Sorted::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
27 28 29 |
# File 'lib/axiom/relation/operation/limit.rb', line 27 def directions @directions end |
#limit ⇒ Integer (readonly)
Return the limit
20 21 22 |
# File 'lib/axiom/relation/operation/limit.rb', line 20 def limit @limit end |
Class Method Details
.new(operand, limit) ⇒ Limit
Instantiate a new Limit
42 43 44 45 46 |
# File 'lib/axiom/relation/operation/limit.rb', line 42 def self.new(operand, limit) assert_sorted_operand(operand) assert_valid_limit(limit) super end |
Instance Method Details
#delete ⇒ undefined
Raise an exception when deleting from the Limit
147 148 149 |
# File 'lib/axiom/relation/operation/limit.rb', line 147 def delete(*) fail ImmutableRelationError, 'deleting from a limit is impossible' end |
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set
112 113 114 115 116 117 118 119 |
# File 'lib/axiom/relation/operation/limit.rb', line 112 def each return to_enum unless block_given? operand.each_with_index do |tuple, index| break if @limit == index yield tuple end self end |
#insert ⇒ undefined
Raise an exception when inserting into the Limit
132 133 134 |
# File 'lib/axiom/relation/operation/limit.rb', line 132 def insert(*) fail ImmutableRelationError, 'inserting into a limit is impossible' end |