Class: Trestle::Toolbar

Inherits:
Object
  • Object
show all
Defined in:
lib/trestle/toolbar.rb,
lib/trestle/toolbar/item.rb,
lib/trestle/toolbar/menu.rb,
lib/trestle/toolbar/builder.rb,
lib/trestle/toolbar/context.rb

Defined Under Namespace

Classes: Block, Builder, Button, Context, Dropdown, Item, Link, Menu

Instance Method Summary collapse

Constructor Details

#initialize(builder = Builder) ⇒ Toolbar

Returns a new instance of Toolbar.



8
9
10
11
# File 'lib/trestle/toolbar.rb', line 8

def initialize(builder=Builder)
  @builder = builder
  clear!
end

Instance Method Details

#append(&block) ⇒ Object



26
27
28
# File 'lib/trestle/toolbar.rb', line 26

def append(&block)
  @blocks.push(Block.new(&block))
end

#clear!Object



13
14
15
# File 'lib/trestle/toolbar.rb', line 13

def clear!
  @blocks = []
end

#groups(template, *args) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/trestle/toolbar.rb', line 17

def groups(template, *args)
  Enumerator.new do |y|
    @blocks.each do |block|
      builder = @builder.new(template, *args)
      block.evaluate(builder, template, y, *args)
    end
  end
end

#prepend(&block) ⇒ Object



30
31
32
# File 'lib/trestle/toolbar.rb', line 30

def prepend(&block)
  @blocks.unshift(Block.new(&block))
end