lib/rmega/nodes/folder.rb in rmega-0.1.7 vs lib/rmega/nodes/folder.rb in rmega-0.2.0
- old
+ new
@@ -1,27 +1,17 @@
-require 'rmega/crypto/crypto'
-require 'rmega/utils'
-require 'rmega/nodes/node'
-require 'rmega/nodes/expandable'
-require 'rmega/nodes/traversable'
-require 'rmega/nodes/deletable'
-
module Rmega
module Nodes
class Folder < Node
include Expandable
include Traversable
include Deletable
def download(path)
+ path = ::File.join(path, self.name)
+ FileUtils.mkdir_p(path)
+
children.each do |node|
- if node.type == :file
- node.download path
- elsif node.type == :folder
- subfolder = ::File.expand_path ::File.join(path, node.name)
- Dir.mkdir(subfolder) unless Dir.exists?(subfolder)
- node.download subfolder
- end
+ node.download(path)
end
nil
end
end