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
- VERSION =
"1.0.0"
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.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/svg_sprite.rb', line 37 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.
34 35 36 |
# File 'lib/svg_sprite.rb', line 34 def css_path @css_path end |
#fill ⇒ Object (readonly)
Returns the value of attribute fill.
34 35 36 |
# File 'lib/svg_sprite.rb', line 34 def fill @fill end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
34 35 36 |
# File 'lib/svg_sprite.rb', line 34 def input @input end |
#input_files ⇒ Object (readonly)
Returns the value of attribute input_files.
34 35 36 |
# File 'lib/svg_sprite.rb', line 34 def input_files @input_files end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/svg_sprite.rb', line 34 def name @name end |
#optimize ⇒ Object (readonly)
Returns the value of attribute optimize.
34 35 36 |
# File 'lib/svg_sprite.rb', line 34 def optimize @optimize end |
#sprite_path ⇒ Object (readonly)
Returns the value of attribute sprite_path.
34 35 36 |
# File 'lib/svg_sprite.rb', line 34 def sprite_path @sprite_path end |
#stroke ⇒ Object (readonly)
Returns the value of attribute stroke.
34 35 36 |
# File 'lib/svg_sprite.rb', line 34 def stroke @stroke end |
Class Method Details
.call(name:, input:, sprite_path:, css_path:, optimize: true, stroke: nil, fill: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/svg_sprite.rb', line 19 def self.call( name:, input:, sprite_path:, css_path:, 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 ).call end |
Instance Method Details
#call ⇒ Object
50 51 52 53 |
# File 'lib/svg_sprite.rb', line 50 def call save_file sprite_path, svg_sprite save_file css_path, manifest(css_definitions.chomp) end |