class Object

Public Instance Methods

get_hash_file(filename) click to toggle source
# File lib/config_worker.rb, line 21
def get_hash_file filename
  if File.exist?(filename)
    keys_to_sym YAML.load_file(filename)
  else
    nil
  end
end
keys_to_str(src) click to toggle source
# File lib/config_worker.rb, line 12
def keys_to_str src
  if src.is_a? Array
    src.map {|item| keys_to_str item}
  elsif src.is_a? Hash
    Hash[src.map {|k, v| [k.to_s, keys_to_str(v)]}]
  else
    src
  end
end
keys_to_sym(src) click to toggle source
# File lib/config_worker.rb, line 3
def keys_to_sym src
  if src.is_a? Array
    src.map {|item| keys_to_sym item}
  elsif src.is_a? Hash
    Hash[src.map {|k, v| ["#{k}".to_sym, keys_to_sym(v)]}]
  else
    src
  end
end
put_hash_file(filename, props) click to toggle source
# File lib/config_worker.rb, line 28
def put_hash_file filename, props
  File.open(filename, 'w') do |f|
    f.write((keys_to_str props).to_yaml)
  end
end