Class: Tabled::ContentShaper
- Inherits:
-
Object
- Object
- Tabled::ContentShaper
- Defined in:
- lib/content_shaper.rb
Instance Attribute Summary collapse
-
#columns_width ⇒ Object
Returns the value of attribute columns_width.
-
#data ⇒ Object
Returns the value of attribute data.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(data, columns_width, options) ⇒ ContentShaper
constructor
A new instance of ContentShaper.
- #shape ⇒ Object
Constructor Details
#initialize(data, columns_width, options) ⇒ ContentShaper
Returns a new instance of ContentShaper.
7 8 9 10 11 |
# File 'lib/content_shaper.rb', line 7 def initialize(data, columns_width, ) @data = data @columns_width = columns_width @options = end |
Instance Attribute Details
#columns_width ⇒ Object
Returns the value of attribute columns_width.
5 6 7 |
# File 'lib/content_shaper.rb', line 5 def columns_width @columns_width end |
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/content_shaper.rb', line 5 def data @data end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/content_shaper.rb', line 5 def @options end |
Instance Method Details
#shape ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/content_shaper.rb', line 13 def shape content = [] unless [:titles].empty? content << Tabled::Template::Titles.render([:titles], columns_width, [:framed]) content << ([:row_separator].to_s * row_length) unless [:row_separator].nil? end content.concat( data .each_with_object([]) do |row, enumerator| enumerator << Tabled::Template::Row.render(row, columns_width, [:framed]) enumerator << Tabled::Template::RowFooter.render(row, columns_width, [:framed]) # Row separator enumerator << ([:row_separator].to_s * row_length) unless [:row_separator].nil? end .compact ) content = add_left_and_right_borders(content) add_top_bottom_borders(content) end |