Class: ACopy
- Inherits:
-
Object
- Object
- ACopy
- Defined in:
- lib/acopy.rb
Instance Attribute Summary collapse
-
#cpdatas ⇒ Object
readonly
Returns the value of attribute cpdatas.
-
#xml_file_path ⇒ Object
readonly
Returns the value of attribute xml_file_path.
Instance Method Summary collapse
-
#initialize(xml_path) ⇒ ACopy
constructor
A new instance of ACopy.
- #read ⇒ Object
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
#cpdatas ⇒ Object (readonly)
Returns the value of attribute cpdatas.
7 8 9 |
# File 'lib/acopy.rb', line 7 def cpdatas @cpdatas end |
#xml_file_path ⇒ Object (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
#read ⇒ Object
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 |