Class: HtmlOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/showcase/helpers/html_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HtmlOptions

Returns a new instance of HtmlOptions.


2
3
4
# File 'lib/showcase/helpers/html_options.rb', line 2

def initialize(options = {})
  @options = (options || {}).symbolize_keys
end

Instance Method Details

#add_class!(css_class) ⇒ Object


6
7
8
9
10
11
# File 'lib/showcase/helpers/html_options.rb', line 6

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


13
14
15
16
# File 'lib/showcase/helpers/html_options.rb', line 13

def merge_attrs!(options = {})
  options = (options || {}).symbolize_keys
  @options.merge!(options)
end

#to_hObject


18
19
20
# File 'lib/showcase/helpers/html_options.rb', line 18

def to_h
  @options.dup
end