Sha256: ac2fdd991430a068ffa1b4df354728a6d6bbda4bca9f74d8d41b2cf670fe54ba

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

Contents

require 'nokogiri'

module ISE

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

    attr_accessor :filename 

    #
    # Creates a new ISE Project from an XML string or file object. 
    #
    def initialize(xml, filename)
      @xml = Nokogiri.XML(xml)
      @filename = filename
      @base_path = File.dirname(filename)
    end

    #
    # Factory method which creates a new instance from an XML file.
    #
    def self.load(file_path)
      new(File::read(file_path), file_path)
    end

    #
    # Writes the project to disk, saving any changes.
    #
    def save(file_path=@filename)
      File::write(file_path, @xml)
    end
    
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-ise-1.0.0 lib/ise/xml_file.rb
ruby-ise-0.6.1 lib/ise/xml_file.rb