Class: SvgDocument

Inherits:
Object show all
Defined in:
lib/gamebox/core/svg_document.rb

Defined Under Namespace

Modules: HasBounds, HasTranslation Classes: Base, Group, Image, Path, Rectangle

Instance Method Summary collapse

Constructor Details

#initialize(xml_string) ⇒ SvgDocument

Returns a new instance of SvgDocument.



7
8
9
10
# File 'lib/gamebox/core/svg_document.rb', line 7

def initialize(xml_string)
  @document = REXML::Document.new(xml_string)
  @root = @document.root
end

Instance Method Details

#find_group_by_label(label) ⇒ Object



12
13
14
15
16
# File 'lib/gamebox/core/svg_document.rb', line 12

def find_group_by_label(label)
  g = REXML::XPath.first(@root, "//g[@inkscape:label='#{label}']")
  return nil unless g
  Group.new(g)
end