Class: Data_table
- Inherits:
-
Object
- Object
- Data_table
- Includes:
- Deep_dup
- Defined in:
- lib/models/data_table/data_table.rb
Instance Method Summary collapse
-
#col_count ⇒ Object
column count.
-
#get(row, col) ⇒ Object
get element.
-
#initialize(data) ⇒ Data_table
constructor
constructor.
-
#row_count ⇒ Object
row count.
Methods included from 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_count ⇒ Object
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
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_count ⇒ Object
row count
12 13 14 |
# File 'lib/models/data_table/data_table.rb', line 12 def row_count self.data.size end |