Class: YamlDumper

Inherits:
Dumper show all
Defined in:
lib/xcode-yamlizer/dumpers.rb

Instance Method Summary collapse

Methods inherited from Dumper

#initialize

Constructor Details

This class inherits a constructor from Dumper

Instance Method Details

#_hash_clean(obj) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/xcode-yamlizer/dumpers.rb', line 37

def _hash_clean(obj)
  if obj.respond_to?(:key?) && obj.key?(nil)
    obj.delete(nil)
  end
  if obj.respond_to?(:each)
    obj.find{ |*a| _hash_clean(a.last) }
  end
end

#dump(object) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/xcode-yamlizer/dumpers.rb', line 28

def dump(object)
  result = YAML::dump(object)
  if result
    File.open(@filename, 'w') do |f|
      f.write(result)
    end
  end
end

#loadObject



45
46
47
48
49
# File 'lib/xcode-yamlizer/dumpers.rb', line 45

def load()
  result = YAML::load_file(@filename)
  _hash_clean(result)
  return result
end