Class: Woodhouse::LayoutBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/woodhouse/layout_builder.rb

Defined Under Namespace

Classes: NodeBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, layout = nil) {|_self| ... } ⇒ LayoutBuilder

Returns a new instance of LayoutBuilder

Yields:

  • (_self)

Yield Parameters:



43
44
45
46
47
48
# File 'lib/woodhouse/layout_builder.rb', line 43

def initialize(config, layout = nil)
  @config = config
  @layout = layout || Woodhouse::Layout.new
  @nodes ||= {}
  yield self if block_given?
end

Instance Attribute Details

#layoutObject (readonly)

Returns the value of attribute layout



3
4
5
# File 'lib/woodhouse/layout_builder.rb', line 3

def layout
  @layout
end

Instance Method Details

#node(name) {|@nodes[name] ||= NodeBuilder.new(@config, @layout.node(name))| ... } ⇒ Object

Yields:

  • (@nodes[name] ||= NodeBuilder.new(@config, @layout.node(name)))


50
51
52
53
# File 'lib/woodhouse/layout_builder.rb', line 50

def node(name)
  @layout.node(name) || @layout.add_node(name)
  yield(@nodes[name] ||= NodeBuilder.new(@config, @layout.node(name)))
end