Class: Data_table

Inherits:
Object
  • Object
show all
Includes:
Deep_dup
Defined in:
lib/models/data_table/data_table.rb

Instance Method Summary collapse

Methods included from Deep_dup

#deep_dup

Constructor Details

#initialize(data) ⇒ Data_table

constructor



7
8
9
# File 'lib/models/data_table/data_table.rb', line 7

def initialize(data)
    self.data = data
end

Instance Method Details

#col_countObject

column count



17
18
19
20
21
22
# File 'lib/models/data_table/data_table.rb', line 17

def col_count
    if self.data.empty?
        return 0
    end
    self.data[0].size
end

#get(row, col) ⇒ Object

get element

Raises:

  • (IndexError)


25
26
27
28
29
# File 'lib/models/data_table/data_table.rb', line 25

def get(row, col)
    raise IndexError, "Row out of bounds" unless self.valid_row?(row)
    raise IndexError, "Column out of bounds" unless self.valid_col?(col)
    self.deep_dup(self.data[row][col])
end

#row_countObject

row count



12
13
14
# File 'lib/models/data_table/data_table.rb', line 12

def row_count
    self.data.size
end