Method: Atom::Tools#entries_to_dir
- Defined in:
- lib/atom/tools.rb
#entries_to_dir(entries, path) ⇒ Object
saves an Array of Atom::Entrys to a directory
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/atom/tools.rb', line 41 def entries_to_dir entries, path if File.exists? path raise "directory #{path} already exists" else Dir.mkdir path end entries.each do |entry| e = entry.to_s new_filename = path + '/0x' + MD5.new(e).hexdigest[0,8] + '.atom' File.open(new_filename, 'w') { |f| f.write e } end end |