Class: Rglpk::RowColArray
Instance Method Summary collapse
- #[](i) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ RowColArray
constructor
A new instance of RowColArray.
- #size ⇒ Object
Constructor Details
#initialize ⇒ RowColArray
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 |
#size ⇒ Object
17 18 19 |
# File 'lib/rglpk.rb', line 17 def size @array.size end |