Class: Fidelity::Widget::Tab

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

Defined Under Namespace

Classes: TabPanel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Tab.



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

def initialize template, options={}
  @template = template
  @vertical = true if options[:orientation] and options[:orientation].to_sym == :vertical
  @tabs = []
end

Instance Attribute Details

#tabsObject

Returns the value of attribute tabs.



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

def tabs
  @tabs
end

#templateObject

Returns the value of attribute template.



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

def template
  @template
end

#verticalObject

Returns the value of attribute vertical.



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

def vertical
  @vertical
end

Instance Method Details

#eachObject



19
20
21
22
23
# File 'app/fidelity/widgets/tabs/tabs.rb', line 19

def each
  @tabs.each do |tab|
    yield tab
  end
end

#tab(label = 'Tab', options = {}, &block) ⇒ Object



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

def tab label='Tab', options={}, &block
  panel = Proc.new{ options[:text] }
  panel = template.capture(&block) if block_given?
  state = :active if options[:state]
  @tabs << TabPanel.new(label, panel, state)
end