Class: Bookify::Node::Table
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#break_if_close_to_bottom, #clean_html, #decode_html, #font, #html_classes, #initialize, #method_missing, render
Constructor Details
This class inherits a constructor from Bookify::Node::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Bookify::Node::Base
Instance Method Details
#render ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bookify/node/table.rb', line 5 def render font :primary table table_data, header: true, width: bounds.width do cells.borders = [] row(0).borders = [:top, :bottom] row(0).border_top_width = 0.5 row(0).border_bottom_width = 0.5 row(0).font_style = :bold row(-1).borders = [:bottom] row(-1).border_bottom_width = 0.5 cells.columns(0).padding = [5, 5, 5, 0] cells.columns(-1).padding = [5, 0, 5, 5] end move_down 15 end |
#table_data ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/bookify/node/table.rb', line 26 def table_data node.css("tr").map do |tr| tr.css("th, td").map do |td| decode_html(td.inner_html.strip) end end end |