module YAMLInteraction

Public Instance Methods

key_value_add(file_location, key, value) click to toggle source
# File lib/html_compilation/modules/yaml_interaction.rb, line 8
def key_value_add(file_location, key, value)
  hash = return_yaml(file_location)
  hash.store(key.upcase.tr(' ', '_'), value.to_s)
  yaml_dump(file_location, hash)
end
read_yaml(relative_location, data) click to toggle source
# File lib/html_compilation/modules/yaml_interaction.rb, line 4
def read_yaml(relative_location, data)
  return_yaml(relative_location)[data.upcase.tr(' ', '_')]
end

Private Instance Methods

return_yaml(relative_location) click to toggle source
# File lib/html_compilation/modules/yaml_interaction.rb, line 16
def return_yaml(relative_location)
  YAML.load(File.read(relative_location))
end
yaml_dump(file_location, hash) click to toggle source
# File lib/html_compilation/modules/yaml_interaction.rb, line 20
def yaml_dump(file_location, hash)
  File.open(file_location, 'w+') {
      |file| YAML.dump(hash, file)}
end