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.



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

def initialize(doc, local_directory = "")
  @doc = doc
  @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(Nokogiri::XML(File.read(path)))
end

.from_xml(xml) ⇒ Object



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

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

Instance Method Details

#callObject



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

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



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

def to_xml
  call.to_xml
end