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.



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

#maxObject (readonly)

Gets the maximum element of the view.



277
278
279
# File 'lib/gecoder/interface/variables.rb', line 277

def max
  @max
end

#minObject (readonly)

Gets the minimum element of the view.



275
276
277
# File 'lib/gecoder/interface/variables.rb', line 275

def min
  @min
end

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