Class: Matrix
- Inherits:
-
Object
- Object
- Matrix
- Defined in:
- lib/primes_table/matrix.rb
Instance Attribute Summary collapse
-
#columns_header ⇒ Object
Returns the value of attribute columns_header.
-
#rows_header ⇒ Object
Returns the value of attribute rows_header.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(args) ⇒ Matrix
constructor
A new instance of Matrix.
- #print ⇒ Object
Constructor Details
#initialize(args) ⇒ Matrix
Returns a new instance of Matrix.
6 7 8 9 10 11 12 |
# File 'lib/primes_table/matrix.rb', line 6 def initialize(args) rows = header(args[:rows]) columns = header(args[:columns]) @table = load_table(rows, columns) @rows_header = rows @columns_header = columns end |
Instance Attribute Details
#columns_header ⇒ Object
Returns the value of attribute columns_header.
4 5 6 |
# File 'lib/primes_table/matrix.rb', line 4 def columns_header @columns_header end |
#rows_header ⇒ Object
Returns the value of attribute rows_header.
4 5 6 |
# File 'lib/primes_table/matrix.rb', line 4 def rows_header @rows_header end |
#table ⇒ Object
Returns the value of attribute table.
4 5 6 |
# File 'lib/primes_table/matrix.rb', line 4 def table @table end |
Instance Method Details
#print ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/primes_table/matrix.rb', line 14 def print distance = last_value.to_s.length puts format_columns_header(distance) table.each_with_index do |row, index| puts format_rows(row, index, distance) end end |