Sha256: dc2ddeb08b0196973379c4cc223e95d814bac337b51948082f127b3b6f31c949

Contents?: true

Size: 597 Bytes

Versions: 10

Compression:

Stored size: 597 Bytes

Contents

require_relative "value_parser"

module Eye::Patch

  class Settings

    def initialize(filename)
      @settings = YAML.load(File.open(filename))
    end

    def [](value)
      parsed[value]
    end

    private

    def parsed
      @parsed ||= parse(@settings)
    end

    def parse(item)
      case item
      when Hash
        item.each_with_object({}) do |(key, val), result|
          result[key.to_sym] = parse(val)
        end
      when Array
        item.map { |val| parse(val) }
      when String
        ValueParser.parse(item)
      else
        item
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
eye-patch-0.1.4 lib/eye/patch/settings.rb
eye-patch-0.1.3 lib/eye/patch/settings.rb
eye-patch-0.1.2 lib/eye/patch/settings.rb
eye-patch-0.1.1 lib/eye/patch/settings.rb
eye-patch-0.1.0 lib/eye/patch/settings.rb
eye-patch-0.0.9 lib/eye/patch/settings.rb
eye-patch-0.0.8 lib/eye/patch/settings.rb
eye-patch-0.0.7 lib/eye/patch/settings.rb
eye-patch-0.0.6 lib/eye/patch/settings.rb
eye-patch-0.0.5 lib/eye/patch/settings.rb