Class: Bamboo::Grid
- Inherits:
-
Object
- Object
- Bamboo::Grid
- Defined in:
- lib/bamboo/grid.rb
Class Method Summary collapse
Class Method Details
.modular(columns = 2, scale = Bamboo::GOLDEN_RATIO) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bamboo/grid.rb', line 11 def self.modular(columns = 2, scale = Bamboo::GOLDEN_RATIO) column_widths = [] used_width = 0 available_width = Bamboo::TOTAL_WIDTH columns.times do |index| if index == columns - 1 column_widths.push available_width else width = available_width / scale column_widths.push width available_width = available_width - width used_width = used_width + width end end { column_widths: column_widths, css: css(column_widths) } end |
.uniform(columns = 12) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/bamboo/grid.rb', line 3 def self.uniform(columns = 12) column_widths = [] single_width = Bamboo::TOTAL_WIDTH / Float(columns) columns.times { |index| column_widths.push single_width * (index + 1) } { column_widths: column_widths, css: css(column_widths) } end |