Table class to fill array structure with values
Refactored Code

This is a possible way to refactor the code to meet the style guidelines of Ruby using Rubocop.

# frozen_string_literal: true

# A simple table with rows and cols
class Table
  attr_reader :grid

  def initialize(rows:, columns:)
    @grid = construct(rows, columns)
  end

  def construct(rows, columns)
    unless rows.is_a?(Array) &amp;&amp; columns.is_a?(Array)
      raise 'arguments must be arrays'
    end

    table = []
    rows = [] if rows.nil?
    rows.each do |_row|
      table &lt;&lt; columns.map { |c| c }
    end
    table
  end
end




Style Considerations

A guard clause should be appended wih an empty line. Also, since the line is over 80 characters, split it up in multi-line.


raise 'arguments must be arrays' unless rows.is_a?(Array) &amp;&amp; columns.is_a?(Array)
table = []



unless rows.is_a?(Array) &amp;&amp; columns.is_a?(Array)
  raise 'arguments must be arrays'
end

table = []


You have an unused block argument row and the map should be rewritten using {..}.


rows.each do |row|
  table &lt;&lt; columns.map do |c| c end
end



rows.each do |_row|
  table &lt;&lt; columns.map { |c| c }
end




General Guidelines and Conventions

The tool also complained about the following guidelines.


use 2 instead of 4 white spaces for indentation
remove any trailing white space
remove space before comma
add a frozen string literal comment justification
add top level class documentation comment