Class: Healthicons::Transform
- Inherits:
-
Object
- Object
- Healthicons::Transform
- Defined in:
- lib/healthicons/transform.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ 'aria-hidden' => true, stroke: 'currentColor', focusable: false, role: 'img', size: 24 }.freeze
- HEIGHT_AND_WIDTH =
%i[height width].freeze
- KEYS_TO_REMOVE =
%i[height width variant viewbox xmlns].freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#svg ⇒ Object
Returns the value of attribute svg.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(svg, options = {}) ⇒ Transform
constructor
Used when transforming a new SVG::XML icon.
-
#render ⇒ String
Generate and return the SVG’s altered XML contents.
Constructor Details
#initialize(svg, options = {}) ⇒ Transform
Used when transforming a new SVG::XML icon
25 26 27 28 |
# File 'lib/healthicons/transform.rb', line 25 def initialize(svg, = {}) @svg = parse_icon_content(svg) @options = () end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/healthicons/transform.rb', line 12 def @options end |
#svg ⇒ Object
Returns the value of attribute svg.
12 13 14 |
# File 'lib/healthicons/transform.rb', line 12 def svg @svg end |
Class Method Details
.call(svg, options = {}) ⇒ String
17 18 19 |
# File 'lib/healthicons/transform.rb', line 17 def self.call(svg, = {}) new(svg, ).render end |
Instance Method Details
#render ⇒ String
Generate and return the SVG’s altered XML contents
33 34 35 36 37 38 39 |
# File 'lib/healthicons/transform.rb', line 33 def render return '' if @svg.blank? # used to ensure icons with missing </path> have it added to ensure IE compatibiltiy @svg&.to_html(&:no_empty_tags) end |