Class: Phantom::SVG::Parser::SVGWriter
- Inherits:
-
AbstractImageWriter
- Object
- AbstractImageWriter
- Phantom::SVG::Parser::SVGWriter
- Defined in:
- lib/phantom/parser/svg_writer.rb
Overview
SVG writer.
Instance Method Summary collapse
-
#write(path, object) ⇒ Object
Write svg file from object to path.
Methods inherited from AbstractImageWriter
Constructor Details
This class inherits a constructor from Phantom::SVG::Parser::AbstractImageWriter
Instance Method Details
#write(path, object) ⇒ Object
Write svg file from object to path. Return write size.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/phantom/parser/svg_writer.rb', line 14 def write(path, object) return 0 if path.nil? || path.empty? || object.nil? reset # Parse object. if object.is_a?(Base) then write_animation_svg(object) elsif object.is_a?(Frame) then write_svg(object) else return 0 end # Add svg version. @root.elements['svg'].add_attribute('version', '1.1') # Write to file. File.open(path, 'w') { |file| @root.write(file, 2) } end |