Class: Trestle::Tab

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/trestle/tab.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Tab.



7
8
9
# File 'lib/trestle/tab.rb', line 7

def initialize(name, options={})
  @name, @options = name, options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/trestle/tab.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/trestle/tab.rb', line 5

def options
  @options
end

Instance Method Details

#badgeObject



19
20
21
# File 'lib/trestle/tab.rb', line 19

def badge
  (:span, options[:badge], class: "badge") if options[:badge]
end

#id(tag = nil) ⇒ Object



11
12
13
# File 'lib/trestle/tab.rb', line 11

def id(tag=nil)
  ["tab", tag, name].compact.join("-")
end

#labelObject



15
16
17
# File 'lib/trestle/tab.rb', line 15

def label
  safe_join([options[:label] || I18n.t("admin.tabs.#{name}", default: name.to_s.titleize), badge].compact, " ")
end