Class: ColumnPack::ColumnPacker
- Inherits:
-
Object
- Object
- ColumnPack::ColumnPacker
- Includes:
- ActionView::Context, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
- Defined in:
- lib/column_pack/column_packer.rb
Overview
Arranges HTML elements into a fixed number of columns.
Instance Method Summary collapse
- #add(height, content) ⇒ Object
-
#initialize(total_columns, options = {}) ⇒ ColumnPacker
constructor
Uses a fixed number of columns (total_columns).
-
#render ⇒ Object
Renders all elements into columns.
Constructor Details
#initialize(total_columns, options = {}) ⇒ ColumnPacker
Uses a fixed number of columns (total_columns).
Options: :algorithm specify a different bin packing algorithm (default :best_fit_decreasing)
available algorithms are :best_fit_decreasing, :best_fit_increasing
:shuffle_in_col after packing columns, shuffle the elements in each column (defaults to true)
16 17 18 |
# File 'lib/column_pack/column_packer.rb', line 16 def initialize(total_columns, = {}) @bin_packer = BinPacker.new(total_columns, ) end |
Instance Method Details
#add(height, content) ⇒ Object
20 21 22 |
# File 'lib/column_pack/column_packer.rb', line 20 def add(height, content) @bin_packer.add(height.to_i, content) end |
#render ⇒ Object
Renders all elements into columns.
25 26 27 |
# File 'lib/column_pack/column_packer.rb', line 25 def render wrap(@bin_packer.bins).html_safe end |