Class: Showcase::Helpers::HtmlClassAttribute
- Inherits:
-
Object
- Object
- Showcase::Helpers::HtmlClassAttribute
- Defined in:
- lib/showcase/helpers/html_class_attribute.rb
Instance Method Summary collapse
- #<<(value) ⇒ Object
-
#initialize(value = nil) ⇒ HtmlClassAttribute
constructor
A new instance of HtmlClassAttribute.
- #to_html_attribute ⇒ Object
Constructor Details
#initialize(value = nil) ⇒ HtmlClassAttribute
Returns a new instance of HtmlClassAttribute.
4 5 6 |
# File 'lib/showcase/helpers/html_class_attribute.rb', line 4 def initialize(value = nil) @css_classes = value.to_s.strip.split(/\s+/) end |
Instance Method Details
#<<(value) ⇒ Object
8 9 10 11 |
# File 'lib/showcase/helpers/html_class_attribute.rb', line 8 def <<(value) value = value.to_s.strip.split(/\s+/) @css_classes += value end |
#to_html_attribute ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/showcase/helpers/html_class_attribute.rb', line 13 def to_html_attribute if @css_classes.any? @css_classes.uniq.join(' ') else nil end end |