Class: Arrolio::Content::Table::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/content/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content = [], colspan: 1, rowspan: 1, style_id: :table_cell, align: nil) ⇒ Cell

Returns a new instance of Cell.



85
86
87
88
89
90
91
92
93
# File 'lib/arrolio/content/table.rb', line 85

def initialize(content = [], colspan: 1, rowspan: 1,
               style_id: :table_cell, align: nil)
  @content = Array(content).freeze
  @colspan = colspan.to_i
  @rowspan = rowspan.to_i
  @style_id = style_id.to_sym
  @align = align
  freeze
end

Instance Attribute Details

#alignObject (readonly)

Returns the value of attribute align.



83
84
85
# File 'lib/arrolio/content/table.rb', line 83

def align
  @align
end

#colspanObject (readonly)

Returns the value of attribute colspan.



83
84
85
# File 'lib/arrolio/content/table.rb', line 83

def colspan
  @colspan
end

#contentObject (readonly)

Returns the value of attribute content.



83
84
85
# File 'lib/arrolio/content/table.rb', line 83

def content
  @content
end

#rowspanObject (readonly)

Returns the value of attribute rowspan.



83
84
85
# File 'lib/arrolio/content/table.rb', line 83

def rowspan
  @rowspan
end

#style_idObject (readonly)

Returns the value of attribute style_id.



83
84
85
# File 'lib/arrolio/content/table.rb', line 83

def style_id
  @style_id
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



101
102
103
104
105
106
107
108
# File 'lib/arrolio/content/table.rb', line 101

def ==(other)
  other.is_a?(self.class) &&
    content == other.content &&
    colspan == other.colspan &&
    rowspan == other.rowspan &&
    style_id == other.style_id &&
    align == other.align
end

#hashObject



112
113
114
# File 'lib/arrolio/content/table.rb', line 112

def hash
  [self.class, content, colspan, rowspan, style_id, align].hash
end

#textObject



95
96
97
98
99
# File 'lib/arrolio/content/table.rb', line 95

def text
  @content.map do |node|
    node.is_a?(Paragraph) ? node.text : node.to_s
  end.join(' ')
end