Class: IconHelper::IconCreator

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers, FormatHelper, ValidIcons
Defined in:
app/helpers/icon_helper.rb

Constant Summary

Constants included from ValidIcons

ValidIcons::VALID_ICONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormatHelper

#prepend_class, #squeeze_n_strip

Constructor Details

#initialize(type, options) ⇒ IconCreator

Returns a new instance of IconCreator.



11
12
13
14
# File 'app/helpers/icon_helper.rb', line 11

def initialize(type, options)
  @type    = type
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'app/helpers/icon_helper.rb', line 9

def options
  @options
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'app/helpers/icon_helper.rb', line 8

def type
  @type
end

Instance Method Details

#renderObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/icon_helper.rb', line 16

def render
  icon_options = {
    type:        type,
    size:        options.delete(:size).presence || :normal,
    fw:          options.delete(:fixed_with).presence,
    li:          options.delete(:list_icon).presence,
    inverse:     options.delete(:inverse).presence,
    border:      options.delete(:border).presence,
    pull:        options.delete(:pull).presence,
    animate:     options.delete(:animate).presence,
    orientation: options.delete(:orientation).presence

    # TODO add fa-stack support
    # stack = options.delete(:stack).presence
  }

  prepend_class(options, 'fa', render_fa_class(icon_options))

   :i, nil, options
end