class PnoteClient::Documents::Hml::Table

Attributes

col_count[R]
row_count[R]
rows[R]

Public Class Methods

from_tag(table_tag) click to toggle source
# File lib/pnote_client/documents/hml/table.rb, line 8
def self.from_tag(table_tag)
  row_count = table_tag['RowCount']
  col_count = table_tag['ColCount']

  table = self.new(row_count: row_count.to_i, col_count: col_count.to_i)
  row_tags = table_tag.xpath("ROW")
  row_tags.each do |row_tag|
    table.add_row(TableRow.from_tag(row_tag))
  end

  return table
end
new(row_count: 0, col_count: 0) click to toggle source
# File lib/pnote_client/documents/hml/table.rb, line 23
def initialize(row_count: 0, col_count: 0)
  @row_count = row_count
  @col_count = col_count
  @rows = []
end

Public Instance Methods

add_row(row) click to toggle source
# File lib/pnote_client/documents/hml/table.rb, line 29
def add_row(row)
  @rows << row
end
content() click to toggle source
# File lib/pnote_client/documents/hml/table.rb, line 33
def content
  json = {
    col_count: @col_count,
    row_count: @row_count,
    rows: rows_content
  }.to_json

  return "\n![table](#{json})\n"
end
textable?() click to toggle source
# File lib/pnote_client/documents/hml/table.rb, line 43
def textable?
  return true
end

Private Instance Methods

rows_content() click to toggle source
# File lib/pnote_client/documents/hml/table.rb, line 49
def rows_content
  @rows.map {|row| row.content}
end