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.
282 283 284 285 286 287 288 |
# File 'lib/gecoder/interface/variables.rb', line 282 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.
277 278 279 |
# File 'lib/gecoder/interface/variables.rb', line 277 def max @max end |
#min ⇒ Object (readonly)
Gets the minimum element of the view.
275 276 277 |
# File 'lib/gecoder/interface/variables.rb', line 275 def min @min end |
#size ⇒ Object (readonly)
Gets the number of elements in the view.
273 274 275 |
# File 'lib/gecoder/interface/variables.rb', line 273 def size @size end |
Instance Method Details
#each(&block) ⇒ Object
Iterates over every element in the view.
291 292 293 |
# File 'lib/gecoder/interface/variables.rb', line 291 def each(&block) enum.each(&block) end |