Module: IrHelper

Defined in:
lib/ir_helper.rb,
lib/ir_helper/engine.rb,
lib/ir_helper/helper.rb,
lib/ir_helper/version.rb,
app/helpers/ir_helper/view_helper.rb

Defined Under Namespace

Modules: Helper, ViewHelper Classes: Engine, NoCDNException, NotS3SourceException

Constant Summary collapse

VERSION =
'0.3.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cdnObject

Returns the value of attribute cdn.



8
9
10
# File 'lib/ir_helper.rb', line 8

def cdn
  @cdn
end

.js_backgroundObject (readonly)

Returns the value of attribute js_background.



9
10
11
# File 'lib/ir_helper.rb', line 9

def js_background
  @js_background
end

.js_classObject (readonly)

Returns the value of attribute js_class.



9
10
11
# File 'lib/ir_helper.rb', line 9

def js_class
  @js_class
end

.js_image_tagObject (readonly)

Returns the value of attribute js_image_tag.



9
10
11
# File 'lib/ir_helper.rb', line 9

def js_image_tag
  @js_image_tag
end

.js_urlObject (readonly)

Returns the value of attribute js_url.



9
10
11
# File 'lib/ir_helper.rb', line 9

def js_url
  @js_url
end

Class Method Details

.add_alias(type, name) ⇒ Object



43
44
45
46
47
# File 'lib/ir_helper.rb', line 43

def add_alias(type, name)
  Helper.class_eval do |base|
    base.send(:alias_method, name.to_sym, type.to_sym)
  end
end

.add_js_alias(type, name) ⇒ Object



49
50
51
# File 'lib/ir_helper.rb', line 49

def add_js_alias(type, name)
  instance_variable_set "@#{type.to_s}", name
end

.add_modifier(key, img_tag = '', values = []) ⇒ Object



31
32
33
# File 'lib/ir_helper.rb', line 31

def add_modifier(key, img_tag = '', values = [])
  @modifiers[key.to_sym] = { alias: img_tag, values: values }
end

.add_source(name, option) ⇒ Object



35
36
37
# File 'lib/ir_helper.rb', line 35

def add_source(name, option)
  @modifiers[:e][:values][name.to_sym] = option.to_sym
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (IrHelper)

    the object that the method was called on



11
12
13
# File 'lib/ir_helper.rb', line 11

def configure(&block)
  yield self
end

.modifiersObject



27
28
29
# File 'lib/ir_helper.rb', line 27

def modifiers
  @modifiers ||= default_modifiers
end

.reset_configObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ir_helper.rb', line 15

def reset_config
  @cdn = nil
  @ir_image_tag = nil
  @ir_background = nil
  @ir_url = nil
  @js_class = 'IR'
  @js_image_tag = nil
  @js_background = nil
  @js_url = nil
  @modifiers = default_modifiers
end

.to_hashObject



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ir_helper.rb', line 53

def to_hash
  {
    cdn: cdn,
    ir_image_tag: ir_image_tag,
    ir_background: ir_background,
    ir_url: ir_url,
    js_class: js_class,
    js_image_tag: js_image_tag,
    js_background: js_background,
    js_url: js_url,
    modifiers: modifiers
  }
end