Class: Card::Tab
Overview
tab object, handles tab configuration for view :tabs
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
-
#button_attrib ⇒ Object
-
#content ⇒ Object
-
#initialize(format, name, active_name, config) ⇒ Tab
constructor
A new instance of Tab.
-
#label ⇒ Object
-
#tab_button ⇒ Object
-
#tab_pane(args = nil) ⇒ Object
Constructor Details
#initialize(format, name, active_name, config) ⇒ Tab
Returns a new instance of Tab.
25 26 27 28 29 30 |
# File 'mod/tabs/lib/card/tab.rb', line 25 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.
4 5 6 |
# File 'mod/tabs/lib/card/tab.rb', line 4 def format @format end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'mod/tabs/lib/card/tab.rb', line 4 def name @name end |
Class Method Details
.tab_objects(format, tab_hash, active_name, klass = nil) ⇒ Object
7 8 9 10 11 12 13 |
# File 'mod/tabs/lib/card/tab.rb', line 7 def tab_objects format, tab_hash, active_name, klass=nil klass ||= Card::Tab active_name = active active_name, tab_hash.keys tab_hash.map do |name, config| klass.new format, name, active_name, config end end |
Instance Method Details
#button_attrib ⇒ Object
47 48 49 |
# File 'mod/tabs/lib/card/tab.rb', line 47 def @button_attrib ||= (config_hash? && @config[:button_attr]) || {} end |
#content ⇒ Object
51 52 53 |
# File 'mod/tabs/lib/card/tab.rb', line 51 def content @content ||= config_hash? ? @config[:content] : @config end |
#label ⇒ Object
55 56 57 |
# File 'mod/tabs/lib/card/tab.rb', line 55 def label @label ||= (config_hash? && @config[:title]) || name end |
#tab_button ⇒ Object
32 33 34 35 36 37 |
# File 'mod/tabs/lib/card/tab.rb', line 32 def add_class , "active" if active? wrap_with :li, , role: :presentation, class: "nav-item tab-li-#{name.to_name.key}" end |
#tab_pane(args = nil) ⇒ Object
39 40 41 42 43 44 45 |
# File 'mod/tabs/lib/card/tab.rb', line 39 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 |