Module: TwitterBootstrapMarkup::LabelBase

Included in:
Badge, Label
Defined in:
lib/twitter_bootstrap_markup/label_base.rb

Constant Summary collapse

TYPES =
[:success, :warning, :important, :info, :inverse]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/twitter_bootstrap_markup/label_base.rb', line 9

def self.included(base)

  TYPES.each do |type|
    base.send(:define_method, type) do
      attributes.append!(:class, "#{class_name.downcase}-#{type}")
      self
    end
  end

  TYPES.each do |type|
    base.send(:define_singleton_method, type) do |*args, &block|
      self.new(*args, &block).send(type)
    end
  end

end

Instance Method Details

#initialize(text, attributes = {}) ⇒ Object



5
6
7
# File 'lib/twitter_bootstrap_markup/label_base.rb', line 5

def initialize(text, attributes={})
  super(:span, text, attributes.prepend!(:class, class_name.downcase)) {}
end