Class: UiHelpers::Icon

Inherits:
Element show all
Defined in:
lib/ui_helpers/elements/icon.rb

Constant Summary collapse

ICONS =
{}

Instance Attribute Summary collapse

Attributes inherited from Element

#html_options

Instance Method Summary collapse

Methods inherited from Element

#capture, #classes, #classes=, #initialize, #style=, #tag, #with_html_options

Constructor Details

This class inherits a constructor from UiHelpers::Element

Instance Attribute Details

#h_offsetObject

Returns the value of attribute h_offset.



4
5
6
# File 'lib/ui_helpers/elements/icon.rb', line 4

def h_offset
  @h_offset
end

#heightObject

Returns the value of attribute height.



4
5
6
# File 'lib/ui_helpers/elements/icon.rb', line 4

def height
  @height
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/ui_helpers/elements/icon.rb', line 4

def name
  @name
end

#v_offsetObject

Returns the value of attribute v_offset.



4
5
6
# File 'lib/ui_helpers/elements/icon.rb', line 4

def v_offset
  @v_offset
end

#widthObject

Returns the value of attribute width.



4
5
6
# File 'lib/ui_helpers/elements/icon.rb', line 4

def width
  @width
end

Instance Method Details

#background_styleObject



198
199
200
201
202
203
# File 'lib/ui_helpers/elements/icon.rb', line 198

def background_style
  offsets = [h_offset, v_offset]
  ICONS[name.to_s].gsub(/-?\d+(?=px)/) do |s|
    s.to_i + (offsets.delete_at(0)||0)
  end
end

#height_styleObject



194
195
196
# File 'lib/ui_helpers/elements/icon.rb', line 194

def height_style
  "height: #{height||16 + ((v_offset||0)*1.5).round}px;"
end

#width_styleObject



190
191
192
# File 'lib/ui_helpers/elements/icon.rb', line 190

def width_style
  "width: #{width||16 + ((h_offset||0)*1.5).round}px;"
end