Class: Data_table

Inherits:
Object
  • Object
show all
Defined in:
lib/files/data_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tableObject

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_numberObject



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_numberObject



13
14
15
# File 'lib/files/data_table.rb', line 13

def get_rows_number
  return self.table.size
end