Class: Gecode::EnumerableView
- Inherits:
-
Object
- Object
- Gecode::EnumerableView
- Includes:
- Enumerable
- Defined in:
- lib/gecoder/interface/variables.rb
Overview
Describes an immutable view of an enumerable.
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Gets the maximum element of the view.
-
#min ⇒ Object
readonly
Gets the minimum element of the view.
-
#size ⇒ Object
readonly
Gets the number of elements in the view.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Iterates over every element in the view.
-
#initialize(min, max, size, &enum_constructor) ⇒ EnumerableView
constructor
Constructs a view with the specified minimum, maximum and size.
Constructor Details
#initialize(min, max, size, &enum_constructor) ⇒ EnumerableView
Constructs a view with the specified minimum, maximum and size. The block should construct an enumerable containing the elements of the set.
212 213 214 215 216 217 218 |
# File 'lib/gecoder/interface/variables.rb', line 212 def initialize(min, max, size, &enum_constructor) @min = min @max = max @size = size @constructor = enum_constructor @enum = nil end |
Instance Attribute Details
#max ⇒ Object (readonly)
Gets the maximum element of the view.
207 208 209 |
# File 'lib/gecoder/interface/variables.rb', line 207 def max @max end |
#min ⇒ Object (readonly)
Gets the minimum element of the view.
205 206 207 |
# File 'lib/gecoder/interface/variables.rb', line 205 def min @min end |
#size ⇒ Object (readonly)
Gets the number of elements in the view.
203 204 205 |
# File 'lib/gecoder/interface/variables.rb', line 203 def size @size end |
Instance Method Details
#each(&block) ⇒ Object
Iterates over every element in the view.
221 222 223 |
# File 'lib/gecoder/interface/variables.rb', line 221 def each(&block) enum.each(&block) end |