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(doc, local_directory = "") ⇒ SvgMapping

Returns a new instance of SvgMapping.



33
34
35
36
# File 'lib/vectory/svg_mapping.rb', line 33

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

Class Method Details

.from_path(path) ⇒ Object



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

def self.from_path(path)
  new(Nokogiri::XML(File.read(path)))
end

.from_xml(xml) ⇒ Object



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

def self.from_xml(xml)
  new(Nokogiri::XML(xml))
end

Instance Method Details

#callObject



38
39
40
41
42
43
44
45
46
# File 'lib/vectory/svg_mapping.rb', line 38

def call
  @namespace = Namespace.new(@doc)

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

  @doc
end

#to_xmlObject



48
49
50
# File 'lib/vectory/svg_mapping.rb', line 48

def to_xml
  call.to_xml
end