Class: Interview::Tab

Inherits:
Control show all
Includes:
HasHtmlOptions
Defined in:
lib/interview/controls/tab.rb

Instance Attribute Summary collapse

Attributes included from HasHtmlOptions

#html_class, #html_options

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods included from HasHtmlOptions

#initialize

Methods inherited from Control

#ancestors, #build_child, #build_with_params, #find_attribute, #find_attribute!, #initialize, #set_attributes, #set_defaults

Instance Attribute Details

#activeObject

Returns the value of attribute active.



6
7
8
# File 'lib/interview/controls/tab.rb', line 6

def active
  @active
end

#captionObject

Returns the value of attribute caption.



6
7
8
# File 'lib/interview/controls/tab.rb', line 6

def caption
  @caption
end

Instance Method Details

#build(b) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/interview/controls/tab.rb', line 8

def build(b)
  html_class = @html_class.dup
  html_options = @html_options.dup
  html_class << 'tab-pane'
  html_class << 'active' if @active
  html_options[:id] = @caption if @caption
  b.section html_class: html_class, html_options: html_options do
    yield if block_given?
  end
end

#build_caption(b) ⇒ Object



19
20
21
22
23
24
# File 'lib/interview/controls/tab.rb', line 19

def build_caption(b)
  html_class = control.active ? 'active' : ''
  b.section style: 'li', html_class: html_class do
    b.link caption: @caption, url: "##{@caption}", html_options: { data: { toogle: 'tab' } }
  end
end