class Pulo::FrameRow

Attributes

cells[R]
row_number[RW]

Public Class Methods

new(parent_frame, row_number) click to toggle source
# File lib/pulo/frames/frame_row.rb, line 5
def initialize(parent_frame, row_number)
  @cells=[]
  @parent_frame=parent_frame
  @row_number=row_number
end

Public Instance Methods

[](column) click to toggle source
# File lib/pulo/frames/frame_row.rb, line 19
def [](column)
  if column.is_a?(Integer)
    raise IndexError,"No column number #{column} defined." unless @cells[column]
    @cells[column]
  else
    @parent_frame[column][@row_number]
  end
end
append_column(cell) click to toggle source
# File lib/pulo/frames/frame_row.rb, line 11
def append_column(cell)
  @cells<<cell
end
delete_column(index) click to toggle source
# File lib/pulo/frames/frame_row.rb, line 15
def delete_column(index)
  @cells.delete_at index
end
first_row?() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 83
def first_row?
  @row_number==0
end
inspect() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 63
def inspect
  "Frame Row Object"
end
next_row() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 52
def next_row
  if @row_number<@parent_frame.row_count
    @parent_frame.rows[@row_number+1]
  else
    nil
  end
end
next_rows() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 36
def next_rows
  Enumerator.new do |y|
    for i in (@row_number+1)..@parent_frame.row_count-1
      y.yield @parent_frame.rows[i]
    end
  end
end
previous_row() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 44
def previous_row
  if @row_number>0
    @parent_frame.rows[@row_number-1]
  else
    nil
  end
end
previous_rows() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 28
def previous_rows
  Enumerator.new do |y|
    for i in (0..(@row_number-1)).reverse_each
      y.yield @parent_frame.rows[i]
    end
  end
end
to_a() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 67
def to_a
  @cells.map {|cell| cell.value}
end
to_a_values() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 71
def to_a_values
  value_cells.map {|cell| cell.value}
end
to_h() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 79
def to_h
  Hash[@parent_frame.column_names.keys.to_a.zip(to_a)]
end
to_s() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 60
def to_s
  "row #{@row_number}:".ljust(9,' ') + " #{((@cells.select {|s| !s.column.hidden?}).map {|c| c.to_s}).join('  ')}"
end
value_cells() click to toggle source
# File lib/pulo/frames/frame_row.rb, line 75
def value_cells
  @cells.find_all { |cell| cell.value_column?}
end