Class: SvgSprite::SVG
- Inherits:
-
Object
- Object
- SvgSprite::SVG
- Defined in:
- lib/svg_sprite/svg.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#fill ⇒ Object
readonly
Returns the value of attribute fill.
-
#optimize ⇒ Object
readonly
Returns the value of attribute optimize.
-
#stroke ⇒ Object
readonly
Returns the value of attribute stroke.
Instance Method Summary collapse
- #height ⇒ Object
- #id ⇒ Object
-
#initialize(filepath, optimize:, stroke:, fill:) ⇒ SVG
constructor
A new instance of SVG.
- #symbol ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(filepath, optimize:, stroke:, fill:) ⇒ SVG
Returns a new instance of SVG.
7 8 9 10 11 12 |
# File 'lib/svg_sprite/svg.rb', line 7 def initialize(filepath, optimize:, stroke:, fill:) @filepath = filepath @optimize = optimize @stroke = stroke @fill = fill end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
5 6 7 |
# File 'lib/svg_sprite/svg.rb', line 5 def filepath @filepath end |
#fill ⇒ Object (readonly)
Returns the value of attribute fill.
5 6 7 |
# File 'lib/svg_sprite/svg.rb', line 5 def fill @fill end |
#optimize ⇒ Object (readonly)
Returns the value of attribute optimize.
5 6 7 |
# File 'lib/svg_sprite/svg.rb', line 5 def optimize @optimize end |
#stroke ⇒ Object (readonly)
Returns the value of attribute stroke.
5 6 7 |
# File 'lib/svg_sprite/svg.rb', line 5 def stroke @stroke end |
Instance Method Details
#height ⇒ Object
28 29 30 |
# File 'lib/svg_sprite/svg.rb', line 28 def height symbol[:height] end |
#id ⇒ Object
32 33 34 |
# File 'lib/svg_sprite/svg.rb', line 32 def id File.basename(filepath, ".*") end |
#symbol ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/svg_sprite/svg.rb', line 14 def symbol @symbol ||= xml.css("svg").first.clone.tap do |node| node.name = "symbol" node.set_attribute :id, id process_stroke(node) process_fill(node) end end |
#width ⇒ Object
24 25 26 |
# File 'lib/svg_sprite/svg.rb', line 24 def width symbol[:width] end |