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, valign: nil) ⇒ Cell

Returns a new instance of Cell.



94
95
96
97
98
99
100
101
102
103
# File 'lib/arrolio/content/table.rb', line 94

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

Instance Attribute Details

#alignObject (readonly)

Returns the value of attribute align.



92
93
94
# File 'lib/arrolio/content/table.rb', line 92

def align
  @align
end

#colspanObject (readonly)

Returns the value of attribute colspan.



92
93
94
# File 'lib/arrolio/content/table.rb', line 92

def colspan
  @colspan
end

#contentObject (readonly)

Returns the value of attribute content.



92
93
94
# File 'lib/arrolio/content/table.rb', line 92

def content
  @content
end

#rowspanObject (readonly)

Returns the value of attribute rowspan.



92
93
94
# File 'lib/arrolio/content/table.rb', line 92

def rowspan
  @rowspan
end

#style_idObject (readonly)

Returns the value of attribute style_id.



92
93
94
# File 'lib/arrolio/content/table.rb', line 92

def style_id
  @style_id
end

#valignObject (readonly)

Returns the value of attribute valign.



92
93
94
# File 'lib/arrolio/content/table.rb', line 92

def valign
  @valign
end

Instance Method Details

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



111
112
113
114
115
116
117
118
119
# File 'lib/arrolio/content/table.rb', line 111

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

#hashObject



123
124
125
# File 'lib/arrolio/content/table.rb', line 123

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

#textObject



105
106
107
108
109
# File 'lib/arrolio/content/table.rb', line 105

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