Class: Arrolio::Content::Table
- Inherits:
-
Object
- Object
- Arrolio::Content::Table
- Defined in:
- lib/arrolio/content/table.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#column_widths ⇒ Object
readonly
Returns the value of attribute column_widths.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #column_count ⇒ Object
- #hash ⇒ Object
-
#initialize(header: [], body: [], column_widths: nil, style_id: :table, id: nil) ⇒ Table
constructor
A new instance of Table.
- #rows ⇒ Object
Constructor Details
#initialize(header: [], body: [], column_widths: nil, style_id: :table, id: nil) ⇒ Table
Returns a new instance of Table.
8 9 10 11 12 13 14 15 16 |
# File 'lib/arrolio/content/table.rb', line 8 def initialize(header: [], body: [], column_widths: nil, style_id: :table, id: nil) @header = header.map { |row| coerce_row(row) }.freeze @body = body.map { |row| coerce_row(row) }.freeze @column_widths = column_widths&.map(&:to_f)&.freeze @style_id = style_id.to_sym @id = id freeze end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/arrolio/content/table.rb', line 6 def body @body end |
#column_widths ⇒ Object (readonly)
Returns the value of attribute column_widths.
6 7 8 |
# File 'lib/arrolio/content/table.rb', line 6 def column_widths @column_widths end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
6 7 8 |
# File 'lib/arrolio/content/table.rb', line 6 def header @header end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/arrolio/content/table.rb', line 6 def id @id end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
6 7 8 |
# File 'lib/arrolio/content/table.rb', line 6 def style_id @style_id end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
26 27 28 29 30 31 32 33 |
# File 'lib/arrolio/content/table.rb', line 26 def ==(other) other.is_a?(self.class) && header == other.header && body == other.body && column_widths == other.column_widths && style_id == other.style_id && id == other.id end |
#column_count ⇒ Object
22 23 24 |
# File 'lib/arrolio/content/table.rb', line 22 def column_count rows.map { |r| r.cells.length }.max || 0 end |
#hash ⇒ Object
37 38 39 |
# File 'lib/arrolio/content/table.rb', line 37 def hash [self.class, header, body, column_widths, style_id, id].hash end |
#rows ⇒ Object
18 19 20 |
# File 'lib/arrolio/content/table.rb', line 18 def rows @header + @body end |