Files
game-data/src/config.rb
T
gballan 516f125ea7
ci/woodpecker/push/woodpecker Pipeline was successful
Fixed a lot of linter warnings
2023-12-11 13:08:46 -05:00

29 lines
512 B
Ruby

# frozen_string_literal: true
require 'yaml'
# Config - loads and manages the app's configuration
class Config
DEFAULT_CONFIG = 'config/defaults.yaml'
def initialize(config_path)
@data = YAML.load_file(DEFAULT_CONFIG)
# merge in user-defined configuration if it exists
@data.merge!(YAML.load_file(config_path)) if File.exist?(config_path)
end
def get(key)
bits = key.split('.')
value = @data
bits.each do |bit|
value = value[bit]
end
return value
end
end