Class: ISE::XMLFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ise/xml_file.rb

Overview

Module which implements the functionality used to wrap an ISE XML file.

Direct Known Subclasses

Project, Symbol

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#filenameObject

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