Class: Rglpk::RowColArray

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rglpk.rb

Direct Known Subclasses

ColArray, RowArray

Instance Method Summary collapse

Constructor Details

#initializeRowColArray

Returns a new instance of RowColArray.



13
14
15
# File 'lib/rglpk.rb', line 13

def initialize
  @array = []
end

Instance Method Details

#[](i) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/rglpk.rb', line 26

def [](i)
  if i.kind_of?(String)
    raise RuntimeError, "no rows" if self[1].nil?
    idx = Glpk_wrapper.send(glp_find_method, self[1].p.lp, i)
    raise ArgumentError, "no row with name #{i.inspect}" if idx == 0
    @array[idx - 1]
  else
   @array[i]
  end
end

#each(&block) ⇒ Object



21
22
23
24
# File 'lib/rglpk.rb', line 21

def each(&block)
  @array.each(&block)
  self
end

#sizeObject



17
18
19
# File 'lib/rglpk.rb', line 17

def size
  @array.size
end