Class: Card::Tab
- Inherits:
-
Object
- Object
- Card::Tab
- Defined in:
- mod/bootstrap/lib/card/tab.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(format, name, active_name, config) ⇒ Tab
constructor
A new instance of Tab.
- #tab_button ⇒ Object
- #tab_pane(args = nil) ⇒ Object
Constructor Details
#initialize(format, name, active_name, config) ⇒ Tab
Returns a new instance of Tab.
17 18 19 20 21 22 |
# File '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
#format ⇒ Object (readonly)
Returns the value of attribute format.
3 4 5 |
# File 'mod/bootstrap/lib/card/tab.rb', line 3 def format @format end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File '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 '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_button ⇒ Object
24 25 26 27 28 29 |
# File 'mod/bootstrap/lib/card/tab.rb', line 24 def add_class , "active" if active? wrap_with :li, , role: :presentation, class: "nav-item tab-li-#{name}" end |
#tab_pane(args = nil) ⇒ Object
31 32 33 34 35 36 37 |
# File '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 |