Class: ISE::XMLFile
- Inherits:
-
Object
- Object
- ISE::XMLFile
- Defined in:
- lib/ise/xml_file.rb
Overview
Module which implements the functionality used to wrap an ISE XML file.
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
Class Method Summary collapse
-
.load(file_path) ⇒ Object
Factory method which creates a new instance from an XML file.
Instance Method Summary collapse
-
#initialize(xml, filename) ⇒ XMLFile
constructor
Creates a new ISE Project from an XML string or file object.
-
#save(file_path = @filename) ⇒ Object
Writes the project to disk, saving any changes.
Constructor Details
#initialize(xml, filename) ⇒ XMLFile
Creates a new ISE Project from an XML string or file object.
16 17 18 19 20 |
# File 'lib/ise/xml_file.rb', line 16 def initialize(xml, filename) @xml = Nokogiri.XML(xml) @filename = filename @base_path = File.dirname(filename) end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
11 12 13 |
# File 'lib/ise/xml_file.rb', line 11 def filename @filename end |
Class Method Details
.load(file_path) ⇒ Object
Factory method which creates a new instance from an XML file.
25 26 27 |
# File 'lib/ise/xml_file.rb', line 25 def self.load(file_path) new(File::read(file_path), file_path) end |
Instance Method Details
#save(file_path = @filename) ⇒ Object
Writes the project to disk, saving any changes.
32 33 34 |
# File 'lib/ise/xml_file.rb', line 32 def save(file_path=@filename) File::write(file_path, @xml) end |