Class: Healthicons::Icon
- Inherits:
-
Object
- Object
- Healthicons::Icon
- Defined in:
- lib/healthicons/icon.rb
Constant Summary collapse
- VARIANTS =
%i[outline solid].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#variant ⇒ Object
Returns the value of attribute variant.
Class Method Summary collapse
-
.call(icon, options = {}) ⇒ String
Generate a new instance of Healthicons and render the SVG icon.
Instance Method Summary collapse
-
#initialize(icon, options = {}) ⇒ Icon
constructor
Instantize an icons attributes.
-
#render ⇒ String
Return the SVG icons contents.
Constructor Details
#initialize(icon, options = {}) ⇒ Icon
Instantize an icons attributes
23 24 25 26 27 |
# File 'lib/healthicons/icon.rb', line 23 def initialize(icon, = {}) @variant = variant_check([:variant]) @name = icon.to_s @options = end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/healthicons/icon.rb', line 8 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/healthicons/icon.rb', line 8 def @options end |
#variant ⇒ Object
Returns the value of attribute variant.
8 9 10 |
# File 'lib/healthicons/icon.rb', line 8 def variant @variant end |
Class Method Details
.call(icon, options = {}) ⇒ String
Generate a new instance of Healthicons and render the SVG icon
15 16 17 |
# File 'lib/healthicons/icon.rb', line 15 def self.call(icon, = {}) new(icon, ).render end |
Instance Method Details
#render ⇒ String
Return the SVG icons contents
32 33 34 35 36 |
# File 'lib/healthicons/icon.rb', line 32 def render return '' if svg_file_contents.blank? Healthicons::Transform.call(svg_file_contents, @options) end |