Class: PnoteClient::Documents::Hml::TableCell

Inherits:
Object
  • Object
show all
Defined in:
lib/pnote_client/documents/hml/table_cell.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row_span: 1, col_span: 1) ⇒ TableCell

Returns a new instance of TableCell.



23
24
25
26
27
# File 'lib/pnote_client/documents/hml/table_cell.rb', line 23

def initialize(row_span: 1, col_span: 1)
  @row_span = row_span
  @col_span = col_span
  @paragraphs = []
end

Instance Attribute Details

#col_spanObject (readonly)

Returns the value of attribute col_span.



21
22
23
# File 'lib/pnote_client/documents/hml/table_cell.rb', line 21

def col_span
  @col_span
end

#paragraphsObject (readonly)

Returns the value of attribute paragraphs.



21
22
23
# File 'lib/pnote_client/documents/hml/table_cell.rb', line 21

def paragraphs
  @paragraphs
end

#row_spanObject (readonly)

Returns the value of attribute row_span.



21
22
23
# File 'lib/pnote_client/documents/hml/table_cell.rb', line 21

def row_span
  @row_span
end

Class Method Details

.from_tag(cell_tag) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pnote_client/documents/hml/table_cell.rb', line 7

def self.from_tag(cell_tag)
  row_span = cell_tag['RowSpan']
  col_span = cell_tag['ColSpan']

  cell = self.new(row_span: row_span.to_i, col_span: col_span.to_i)

  pg_tags = cell_tag.xpath("PARALIST/P")
  pg_tags.each do |pg_tag|
    cell.add_paragraph(Paragraph.from_tag(pg_tag))
  end

  return cell
end

Instance Method Details

#add_paragraph(new_paragraph) ⇒ Object



29
30
31
# File 'lib/pnote_client/documents/hml/table_cell.rb', line 29

def add_paragraph(new_paragraph)
  @paragraphs << new_paragraph
end

#contentObject



33
34
35
36
37
38
39
# File 'lib/pnote_client/documents/hml/table_cell.rb', line 33

def content
  return {
    row_span: @row_span,
    col_span: @col_span,
    content: paragraphs_content
  }
end