Class: Phantom::SVG::Parser::SVGReader

Inherits:
AbstractImageReader show all
Defined in:
lib/phantom/parser/svg_reader.rb

Overview

SVG reader.

Instance Attribute Summary

Attributes inherited from AbstractImageReader

#frames, #has_animation, #height, #loops, #skip_first, #width

Instance Method Summary collapse

Methods inherited from AbstractImageReader

#initialize

Constructor Details

This class inherits a constructor from Phantom::SVG::Parser::AbstractImageReader

Instance Method Details

#read(path, options = {}) ⇒ Object

Read svg file from path.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/phantom/parser/svg_reader.rb', line 13

def read(path, options = {})
  reset

  return if path.nil? || path.empty?

  @path = path
  @marker = Digest::MD5.hexdigest(open(@path).read)

  @root = REXML::Document.new(open(path))
  make_ids_unique() if options[:unique_ids] == true

  if @root.elements['svg'].attributes['id'] == 'phantom_svg'
    read_animation_svg(options)
    @has_animation = true
  else
    read_svg(options)
    @has_animation = false
  end
end