Class: CssClassString::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/css_class_string/helper.rb

Instance Method Summary collapse

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)
  options     = args.last.is_a?(::Hash) ? args.pop : {}
  @class_hash = args.map {|class_name| { class_name => true }}.reduce({}, &:merge)
  @class_hash.merge!(options)
end

Instance Method Details

#to_sObject



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