summaryrefslogtreecommitdiff
path: root/logic/cartridge/default.rb
blob: 24a8e7cbb13407af3d2f104635595ca78965e224 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

require 'yaml'
require 'singleton'

require_relative '../helpers/hash'

module NanoBot
  module Logic
    module Cartridge
      class Default
        include Singleton

        def values
          return @values if @values

          path = File.expand_path('../../static/cartridges/default.yml', __dir__)
          cartridge = YAML.safe_load_file(path, permitted_classes: [Symbol])
          @values = Logic::Helpers::Hash.symbolize_keys(cartridge)
          @values
        end

        def baseline
          return @baseline if @baseline

          path = File.expand_path('../../static/cartridges/baseline.yml', __dir__)
          cartridge = YAML.safe_load_file(path, permitted_classes: [Symbol])
          @baseline = Logic::Helpers::Hash.symbolize_keys(cartridge)
          @baseline
        end
      end
    end
  end
end