Class: Fidelity::Widget::Breadcrumb

Inherits:
Object
  • Object
show all
Defined in:
app/fidelity/widgets/breadcrumb/breadcrumb.rb

Defined Under Namespace

Classes: Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template, options = {}) ⇒ Breadcrumb

Returns a new instance of Breadcrumb.



6
7
8
9
# File 'app/fidelity/widgets/breadcrumb/breadcrumb.rb', line 6

def initialize template, options={}
  @template = template
  @items = []
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



5
6
7
# File 'app/fidelity/widgets/breadcrumb/breadcrumb.rb', line 5

def items
  @items
end

#templateObject

Returns the value of attribute template.



5
6
7
# File 'app/fidelity/widgets/breadcrumb/breadcrumb.rb', line 5

def template
  @template
end

Instance Method Details

#eachObject



17
18
19
20
21
# File 'app/fidelity/widgets/breadcrumb/breadcrumb.rb', line 17

def each
  @items.each do |item|
    yield item
  end
end

#item(label = 'Item', options = {}, &block) ⇒ Object



11
12
13
14
15
# File 'app/fidelity/widgets/breadcrumb/breadcrumb.rb', line 11

def item label='Item', options={}, &block
  content = template.capture(&block) if block_given?
  state = options[:state] || :default
  @items << Item.new(label, content, state, options[:path])
end