Class: SvgSprite
- Inherits:
-
Object
- Object
- SvgSprite
- Defined in:
- lib/svg_sprite.rb,
lib/svg_sprite/cli.rb,
lib/svg_sprite/svg.rb,
lib/svg_sprite/version.rb
Defined Under Namespace
Constant Summary collapse
- NOKOGIRI_SAVE_OPTIONS =
{ save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION }.freeze
- DEFAULT_SPRITE_NAME =
"sprite"
- VERSION =
"1.0.2"
Instance Attribute Summary collapse
-
#css_path ⇒ Object
readonly
Returns the value of attribute css_path.
-
#fill ⇒ Object
readonly
Returns the value of attribute fill.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#input_files ⇒ Object
readonly
Returns the value of attribute input_files.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#optimize ⇒ Object
readonly
Returns the value of attribute optimize.
-
#sprite_path ⇒ Object
readonly
Returns the value of attribute sprite_path.
-
#stroke ⇒ Object
readonly
Returns the value of attribute stroke.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name:, input:, sprite_path:, css_path:, optimize:, stroke:, fill:) ⇒ SvgSprite
constructor
A new instance of SvgSprite.
Constructor Details
#initialize(name:, input:, sprite_path:, css_path:, optimize:, stroke:, fill:) ⇒ SvgSprite
Returns a new instance of SvgSprite.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/svg_sprite.rb', line 44 def initialize( name:, input:, sprite_path:, css_path:, optimize:, stroke:, fill: ) @name = name @input = input @input_files = Dir["#{input}/**/*.svg"].sort @sprite_path = sprite_path @css_path = css_path @optimize = optimize @stroke = stroke @fill = fill end |
Instance Attribute Details
#css_path ⇒ Object (readonly)
Returns the value of attribute css_path.
41 42 43 |
# File 'lib/svg_sprite.rb', line 41 def css_path @css_path end |
#fill ⇒ Object (readonly)
Returns the value of attribute fill.
41 42 43 |
# File 'lib/svg_sprite.rb', line 41 def fill @fill end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
41 42 43 |
# File 'lib/svg_sprite.rb', line 41 def input @input end |
#input_files ⇒ Object (readonly)
Returns the value of attribute input_files.
41 42 43 |
# File 'lib/svg_sprite.rb', line 41 def input_files @input_files end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
41 42 43 |
# File 'lib/svg_sprite.rb', line 41 def name @name end |
#optimize ⇒ Object (readonly)
Returns the value of attribute optimize.
41 42 43 |
# File 'lib/svg_sprite.rb', line 41 def optimize @optimize end |
#sprite_path ⇒ Object (readonly)
Returns the value of attribute sprite_path.
41 42 43 |
# File 'lib/svg_sprite.rb', line 41 def sprite_path @sprite_path end |
#stroke ⇒ Object (readonly)
Returns the value of attribute stroke.
41 42 43 |
# File 'lib/svg_sprite.rb', line 41 def stroke @stroke end |
Class Method Details
.call(input:, sprite_path:, css_path:, name: DEFAULT_SPRITE_NAME, optimize: true, stroke: nil, fill: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/svg_sprite.rb', line 21 def self.call( input:, sprite_path:, css_path:, name: DEFAULT_SPRITE_NAME, optimize: true, stroke: nil, fill: nil ) new( name: name, input: input, sprite_path: sprite_path, css_path: css_path, optimize: optimize, stroke: stroke, fill: fill ).tap(&:call) end |
Instance Method Details
#call ⇒ Object
57 58 59 60 61 |
# File 'lib/svg_sprite.rb', line 57 def call save_file sprite_path, svg_sprite save_file css_path, manifest(css_definitions.chomp) self end |