Class: Facades::Patterns::Tabs::TabPanel

Inherits:
Object
  • Object
show all
Defined in:
lib/facades/patterns/tabs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, options = {}) ⇒ TabPanel

Returns a new instance of TabPanel.



57
58
59
60
61
62
# File 'lib/facades/patterns/tabs.rb', line 57

def initialize(title, options = {})
  @title, @options = title, options
  @options.merge!(:id => tab_id)
  klasses = @options.delete(:class) || ""
  @options.merge!(:class => klasses.split(" ").push("tab").join(" "))
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



55
56
57
# File 'lib/facades/patterns/tabs.rb', line 55

def options
  @options
end

#titleObject

Returns the value of attribute title.



55
56
57
# File 'lib/facades/patterns/tabs.rb', line 55

def title
  @title
end

Instance Method Details

#tab_idObject



64
65
66
67
68
# File 'lib/facades/patterns/tabs.rb', line 64

def tab_id
  return options[:id] if options[:id]
  value = title.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n, '').to_s
  value.gsub(/[']+/, '').gsub(/\W+/, ' ').strip.downcase.gsub(" ", "_")
end