Class: Vectory::SvgMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/vectory/svg_mapping.rb

Defined Under Namespace

Classes: Namespace

Constant Summary collapse

SVG_NS =
"http://www.w3.org/2000/svg".freeze
PROCESSING_XPATH =
"processing-instruction()|.//processing-instruction()".freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml, local_directory = "") ⇒ SvgMapping

Returns a new instance of SvgMapping.



28
29
30
31
# File 'lib/vectory/svg_mapping.rb', line 28

def initialize(xml, local_directory = "")
  @xml = xml
  @local_directory = local_directory
end

Class Method Details

.from_path(path) ⇒ Object



24
25
26
# File 'lib/vectory/svg_mapping.rb', line 24

def self.from_path(path)
  new(File.read(path))
end

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/vectory/svg_mapping.rb', line 33

def call
  xmldoc = Nokogiri::XML(@xml)
  @namespace = Namespace.new(xmldoc)

  xmldoc.xpath(@namespace.ns("//svgmap")).each_with_index do |svgmap, index|
    process_svgmap(svgmap, index)
  end

  xmldoc.to_xml
end