Class: Llmsherpa::TableCell
Overview
A table cell is a block of text. It can have child paragraphs. A table cell has tag ‘table_cell’. A table cell is contained within table rows.
Instance Attribute Summary collapse
-
#cell_node ⇒ Object
Returns the value of attribute cell_node.
-
#cell_value ⇒ Object
Returns the value of attribute cell_value.
-
#col_span ⇒ Object
Returns the value of attribute col_span.
Attributes inherited from Block
#bbox, #block_idx, #block_json, #children, #left, #level, #page_idx, #parent, #sentences, #tag, #top
Instance Method Summary collapse
-
#initialize(cell_json) ⇒ TableCell
constructor
A new instance of TableCell.
- #to_html ⇒ Object
- #to_text ⇒ Object
Methods inherited from Block
#add_child, #chunks, #iter_children, #paragraphs, #parent_chain, #parent_text, #sections, #tables, #to_context_text
Constructor Details
#initialize(cell_json) ⇒ TableCell
Returns a new instance of TableCell.
210 211 212 213 214 215 216 217 218 219 |
# File 'lib/llmsherpa/blocks.rb', line 210 def initialize(cell_json) super(cell_json) @col_span = cell_json["col_span"] if cell_json.key?("col_span") @cell_value = cell_json["cell_value"] @cell_node = if @cell_value.is_a?(String) nil else Paragraph.new(@cell_value) end end |
Instance Attribute Details
#cell_node ⇒ Object
Returns the value of attribute cell_node.
208 209 210 |
# File 'lib/llmsherpa/blocks.rb', line 208 def cell_node @cell_node end |
#cell_value ⇒ Object
Returns the value of attribute cell_value.
208 209 210 |
# File 'lib/llmsherpa/blocks.rb', line 208 def cell_value @cell_value end |
#col_span ⇒ Object
Returns the value of attribute col_span.
208 209 210 |
# File 'lib/llmsherpa/blocks.rb', line 208 def col_span @col_span end |
Instance Method Details
#to_html ⇒ Object
227 228 229 230 231 232 233 234 235 |
# File 'lib/llmsherpa/blocks.rb', line 227 def to_html cell_html = @cell_value cell_html = @cell_node.to_html if @cell_node if @col_span == 1 "<td colSpan='#{@col_span}'>#{cell_html}</td>" else "<td>#{cell_html}</td>" end end |
#to_text ⇒ Object
221 222 223 224 225 |
# File 'lib/llmsherpa/blocks.rb', line 221 def to_text cell_text = @cell_value cell_text = @cell_node.to_text if @cell_node cell_text end |