Class: XRCResource

Inherits:
Object
  • Object
show all
Defined in:
lib/wx_sugar/xrc/xml_resource.rb

Overview

or more definitions of Wx Frames, Dialogs or Panels.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xrc_file) ⇒ XRCResource

Read and seek for classes within the XML file xrc_file



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wx_sugar/xrc/xml_resource.rb', line 8

def initialize(xrc_file)
  @xrc_file = xrc_file
  xml_content = File.read(xrc_file)
  # workaround for an ?bug in recent REXML, which fails to match
  # certain XPath expressions when xmlns is declared
  xml_content.sub!(/xmlns="[^"]+"/, '')
  @xml_doc = REXML::Document.new(xml_content)
  @classes = []
  REXML::XPath.each(@xml_doc.root, "/resource/object") do | elem |
    if xml_klass = XRCClass.extract(elem, @xrc_file)
      @classes << xml_klass
    end
  end
end

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes.



5
6
7
# File 'lib/wx_sugar/xrc/xml_resource.rb', line 5

def classes
  @classes
end

#xrc_fileObject (readonly)

Returns the value of attribute xrc_file.



5
6
7
# File 'lib/wx_sugar/xrc/xml_resource.rb', line 5

def xrc_file
  @xrc_file
end