Class: Fidelity::Widget::Subnav

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

Defined Under Namespace

Classes: Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Subnav.



6
7
8
9
# File 'app/fidelity/widgets/subnav/subnav.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/subnav/subnav.rb', line 5

def items
  @items
end

#templateObject

Returns the value of attribute template.



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

def template
  @template
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#eachObject



18
19
20
21
22
# File 'app/fidelity/widgets/subnav/subnav.rb', line 18

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

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



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

def item options={}, &block
  label = Proc.new{ options[:text] }
  label = template.capture(&block) if block_given?
  state = :active if options[:state]
  @items << Item.new(label, state)
end