Class: Showcase::Helpers::HtmlOptions
- Inherits:
-
Object
- Object
- Showcase::Helpers::HtmlOptions
- Defined in:
- lib/showcase/helpers/html_options.rb
Instance Method Summary collapse
- #add_class!(css_class) ⇒ Object
-
#initialize(options = {}) ⇒ HtmlOptions
constructor
A new instance of HtmlOptions.
- #merge_attrs!(options = {}) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HtmlOptions
Returns a new instance of HtmlOptions.
4 5 6 |
# File 'lib/showcase/helpers/html_options.rb', line 4 def initialize( = {}) @options = ( || {}).symbolize_keys end |
Instance Method Details
#add_class!(css_class) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/showcase/helpers/html_options.rb', line 8 def add_class!(css_class) @options[:class] ||= "" css_classes = @options[:class].split(/\s+/) css_classes << css_class @options[:class] = css_classes.join(" ") end |
#merge_attrs!(options = {}) ⇒ Object
15 16 17 18 |
# File 'lib/showcase/helpers/html_options.rb', line 15 def merge_attrs!( = {}) = ( || {}).symbolize_keys @options.merge!() end |
#to_h ⇒ Object
20 21 22 |
# File 'lib/showcase/helpers/html_options.rb', line 20 def to_h @options.dup end |