Class: CssClassString::Helper
- Inherits:
-
Object
- Object
- CssClassString::Helper
- Defined in:
- lib/css_class_string/helper.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Helper
constructor
A new instance of Helper.
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Helper
Returns a new instance of Helper.
3 4 5 6 7 |
# File 'lib/css_class_string/helper.rb', line 3 def initialize(*args) = args.last.is_a?(::Hash) ? args.pop : {} @class_hash = args.map {|class_name| { class_name => true }}.reduce({}, &:merge) @class_hash.merge!() end |
Instance Method Details
#to_s ⇒ Object
9 10 11 |
# File 'lib/css_class_string/helper.rb', line 9 def to_s @class_hash.map { |((tc, fc), v)| v ? tc : fc }.compact.join(" ") end |