Class: Foundation::Column
- Inherits:
-
Object
- Object
- Foundation::Column
- Defined in:
- lib/foundation_helper.rb
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.
52 53 54 55 56 57 58 |
# File 'lib/foundation_helper.rb', line 52 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.
51 52 53 |
# File 'lib/foundation_helper.rb', line 51 def width @width end |
Instance Method Details
#<<(content) ⇒ Object
65 66 67 68 |
# File 'lib/foundation_helper.rb', line 65 def <<(content) @content << content self end |
#render(depth = 0, w = nil) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/foundation_helper.rb', line 70 def render(depth=0, w=nil) out = (" " * depth) wval = (width || w || 12).i! out += "<div class='#{["small-#{wval} large-#{wval}", '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 |