Class: FakeTree::Runner

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

Instance Method Summary collapse

Instance Method Details

#start(tree_hash, parent = './') ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/faketree/runner.rb', line 3

def start(tree_hash, parent = './')
  tree_hash.each do |key, value|
    if value.is_a? String
      File.write(File.join(parent, key), value)
    elsif value.is_a? Hash
      Dir.mkdir(File.join(parent, key))
      start(value, File.join(parent, key))
    else
      fail "Invalid node of type: #{x.class}"
    end
  end
end