Class: ACopy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_path) ⇒ ACopy

Returns a new instance of ACopy.



9
10
11
12
13
14
15
16
# File 'lib/acopy.rb', line 9

def initialize(xml_path)
	@cpdatas = []
	if File::exist?(xml_path) then
		@xml_file_path = xml_path
	else
		raise("#{xml_path} is invalid.")
	end
end

Instance Attribute Details

#cpdatasObject (readonly)

Returns the value of attribute cpdatas.



7
8
9
# File 'lib/acopy.rb', line 7

def cpdatas
  @cpdatas
end

#xml_file_pathObject (readonly)

Returns the value of attribute xml_file_path.



7
8
9
# File 'lib/acopy.rb', line 7

def xml_file_path
  @xml_file_path
end

Instance Method Details

#readObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/acopy.rb', line 18

def read
	doc = REXML::Document.new(open(@xml_file_path))	
	doc.elements.each('acopy/copy') do |e|
		d = CpData.new
		d.setFrom(e.attributes["from"])
		d.setTo(e.attributes["to"])
		d.setMode(e.attributes["mode"].to_sym)
		@cpdatas[@cpdatas.size] = d
	end
end