Class: PnoteClient::Documents::Hml::Table
- Inherits:
-
Object
- Object
- PnoteClient::Documents::Hml::Table
- Defined in:
- lib/pnote_client/documents/hml/table.rb
Instance Attribute Summary collapse
-
#col_count ⇒ Object
readonly
Returns the value of attribute col_count.
-
#row_count ⇒ Object
readonly
Returns the value of attribute row_count.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Class Method Summary collapse
Instance Method Summary collapse
- #add_row(row) ⇒ Object
- #content ⇒ Object
-
#initialize(row_count: 0, col_count: 0) ⇒ Table
constructor
A new instance of Table.
- #textable? ⇒ Boolean
Constructor Details
#initialize(row_count: 0, col_count: 0) ⇒ Table
Returns a new instance of Table.
23 24 25 26 27 |
# 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 |
Instance Attribute Details
#col_count ⇒ Object (readonly)
Returns the value of attribute col_count.
21 22 23 |
# File 'lib/pnote_client/documents/hml/table.rb', line 21 def col_count @col_count end |
#row_count ⇒ Object (readonly)
Returns the value of attribute row_count.
21 22 23 |
# File 'lib/pnote_client/documents/hml/table.rb', line 21 def row_count @row_count end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
21 22 23 |
# File 'lib/pnote_client/documents/hml/table.rb', line 21 def rows @rows end |
Class Method Details
.from_tag(table_tag) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# 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) = table_tag.xpath("ROW") .each do |row_tag| table.add_row(TableRow.from_tag(row_tag)) end return table end |
Instance Method Details
#add_row(row) ⇒ Object
29 30 31 |
# File 'lib/pnote_client/documents/hml/table.rb', line 29 def add_row(row) @rows << row end |
#content ⇒ Object
33 34 35 36 37 38 39 40 41 |
# 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\n" end |
#textable? ⇒ Boolean
43 44 45 |
# File 'lib/pnote_client/documents/hml/table.rb', line 43 def textable? return true end |