class Coopy::TableStream

Attributes

at[RW]
columns[RW]
h[RW]
row[RW]
src[RW]
t[RW]

Public Class Methods

new(t) click to toggle source
# File lib/lib/coopy/table_stream.rb, line 7
def initialize(t)
  @t = t
  @at = -1
  @h = t.get_height
  @src = nil
  if @h < 0 
    meta = t.get_meta
    raise hx_raise("Cannot get meta information for table") if meta == nil
    @src = meta.get_row_stream
    raise hx_raise("Cannot iterate table") if @src == nil
  end
end

Public Instance Methods

fetch() click to toggle source
# File lib/lib/coopy/table_stream.rb, line 73
def fetch 
  if @at == -1 
    @at+=1
    self.fetch_columns if @src != nil
    return true
  end
  if @src != nil 
    @at = 1
    @row = self.fetch_row
    return @row != nil
  end
  @at+=1
  @at < @h
end
fetch_columns() click to toggle source
# File lib/lib/coopy/table_stream.rb, line 31
def fetch_columns 
  return @columns if @columns != nil
  if @src != nil 
    @columns = @src.fetch_columns
    return @columns
  end
  @columns = Array.new
  begin
    _g1 = 0
    _g = @t.get_width
    while(_g1 < _g) 
      i = _g1
      _g1+=1
      @columns.push(@t.get_cell(i,0))
    end
  end
  @columns
end
fetch_row() click to toggle source
# File lib/lib/coopy/table_stream.rb, line 50
def fetch_row 
  return @src.fetch_row if @src != nil
  return nil if @at >= @h
  row = {}
  begin
    _g1 = 0
    _g = @columns.length
    while(_g1 < _g) 
      i = _g1
      _g1+=1
      begin
        v = @t.get_cell(i,@at)
        begin
          value = v
          row[@columns[i]] = value
        end
        v
      end
    end
  end
  row
end
get_cell(x) click to toggle source
# File lib/lib/coopy/table_stream.rb, line 88
def get_cell(x)
  return @columns[x] if @at == 0
  return @row[@columns[x]] if @row != nil
  @t.get_cell(x,@at)
end
width() click to toggle source
# File lib/lib/coopy/table_stream.rb, line 94
def width 
  self.fetch_columns
  @columns.length
end