Class: Gecode::EnumerableView

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gecoder/interface/variables.rb

Overview

Describes an immutable view of an enumerable.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#maxObject (readonly)

Gets the maximum element of the view.



207
208
209
# File 'lib/gecoder/interface/variables.rb', line 207

def max
  @max
end

#minObject (readonly)

Gets the minimum element of the view.



205
206
207
# File 'lib/gecoder/interface/variables.rb', line 205

def min
  @min
end

#sizeObject (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