Class: Data_table
- Inherits:
-
Object
- Object
- Data_table
- Defined in:
- lib/files/data_table.rb
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #get_cols_number ⇒ Object
- #get_element(row:, col:) ⇒ Object
- #get_rows_number ⇒ Object
-
#initialize(table:) ⇒ Data_table
constructor
A new instance of Data_table.
Constructor Details
#initialize(table:) ⇒ Data_table
Returns a new instance of Data_table.
7 8 9 |
# File 'lib/files/data_table.rb', line 7 def initialize(table:) self.table = table end |
Instance Attribute Details
#table ⇒ Object
Returns the value of attribute table.
6 7 8 |
# File 'lib/files/data_table.rb', line 6 def table @table end |
Instance Method Details
#each(&block) ⇒ Object
17 18 19 20 21 |
# File 'lib/files/data_table.rb', line 17 def each(&block) table.each do |row| block.call(row) end end |
#get_cols_number ⇒ Object
23 24 25 26 |
# File 'lib/files/data_table.rb', line 23 def get_cols_number return 0 if table.size == 0 return self.table[0].size end |
#get_element(row:, col:) ⇒ Object
10 11 12 |
# File 'lib/files/data_table.rb', line 10 def get_element(row:, col:) return self.table[row][col] end |
#get_rows_number ⇒ Object
13 14 15 |
# File 'lib/files/data_table.rb', line 13 def get_rows_number return self.table.size end |