Class: Foundation::Column
- Inherits:
-
Object
- Object
- Foundation::Column
- Defined in:
- lib/foundation_helper.rb
Constant Summary collapse
- WIDTHS =
{ 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven', 12 => 'twelve' }
Instance Attribute Summary collapse
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #<<(content) ⇒ Object
-
#initialize(*args, &block) ⇒ Column
constructor
A new instance of Column.
- #render(depth = 0, w = nil) ⇒ Object
- #row(*args, &block) ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Column
Returns a new instance of Column.
54 55 56 57 58 59 60 |
# File 'lib/foundation_helper.rb', line 54 def initialize(*args, &block) @content, @classes, @width = [], args.select { |arg| !arg.is_a? Fixnum }, args.find{ |arg| arg.is_a? Fixnum } if block content = instance_exec(self, &block) @content << content if content != self end end |
Instance Attribute Details
#width ⇒ Object (readonly)
Returns the value of attribute width.
53 54 55 |
# File 'lib/foundation_helper.rb', line 53 def width @width end |
Instance Method Details
#<<(content) ⇒ Object
67 68 69 70 |
# File 'lib/foundation_helper.rb', line 67 def <<(content) @content << content self end |
#render(depth = 0, w = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/foundation_helper.rb', line 72 def render(depth=0, w=nil) out = (" " * depth) out += "<div class='#{[WIDTHS[(width || w || 12).i!], 'columns', *@classes].join(' ')}'>\n" @content.each do |content| if content.is_a?(Foundation::Row) out += content.render(depth + 1) else out += (" " * (depth + 1)) out += content.to_s out += "\n" end end out += (" " * depth) out += "</div>\n" out end |
#row(*args, &block) ⇒ Object
62 63 64 65 |
# File 'lib/foundation_helper.rb', line 62 def row(*args, &block) @content << Row.new(*args, &block) self end |