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.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/phantom/parser/svg_writer.rb', line 13 def write(path, object) return 0 if path.nil? || path.empty? || object.nil? reset # Parse object. return 0 unless write_proc(object) # Add svg version. @root.elements['svg'].add_attribute('version', '1.1') # Write to file. File.open(path, 'w') { |file| @root.write(file, 2) } end |