Class: Card::Tab

Inherits:
Object show all
Defined in:
card-mod-bootstrap/lib/card/tab.rb

Direct Known Subclasses

LazyTab

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format, name, active_name, config) ⇒ Tab

Returns a new instance of Tab.



17
18
19
20
21
22
# File 'card-mod-bootstrap/lib/card/tab.rb', line 17

def initialize format, name, active_name, config
  @format = format
  @name = name
  @active_name = active_name
  @config = config
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



3
4
5
# File 'card-mod-bootstrap/lib/card/tab.rb', line 3

def format
  @format
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'card-mod-bootstrap/lib/card/tab.rb', line 3

def name
  @name
end

Class Method Details

.tab_objects(format, tab_hash, active_name, klass = nil) ⇒ Object



6
7
8
9
10
11
12
# File 'card-mod-bootstrap/lib/card/tab.rb', line 6

def tab_objects format, tab_hash, active_name, klass=nil
  klass ||= Card::Tab
  active_name ||= tab_hash.keys.first
  tab_hash.map do |name, config|
    klass.new format, name, active_name, config
  end
end

Instance Method Details

#tab_buttonObject



24
25
26
27
28
29
# File 'card-mod-bootstrap/lib/card/tab.rb', line 24

def tab_button
  add_class button_attrib, "active" if active?
  wrap_with :li, tab_button_link,
            role: :presentation,
            class: "nav-item tab-li-#{name}"
end

#tab_pane(args = nil) ⇒ Object



31
32
33
34
35
36
37
# File 'card-mod-bootstrap/lib/card/tab.rb', line 31

def tab_pane args=nil
  pane_attr = { role: :tabpanel, id: tab_id }
  pane_attr.merge! args if args.present?
  add_class pane_attr, "tab-pane tab-pane-#{name}"
  add_class pane_attr, "active" if active?
  wrap_with :div, content, pane_attr
end