Sha256: a51863154b128607a41a9376432c0c7b654b886b2c9c5c821e2a174f6143d48f

Contents?: true

Size: 464 Bytes

Versions: 1

Compression:

Stored size: 464 Bytes

Contents

module NagiosParser
  class Result
    def initialize(options = {})
      @options = options
      @result = {}
    end

    def []=(key, value)
      if multi_value?(key)
        (@result[key] ||= []) << value
      else
        @result[key] = value
      end
    end

    def [](key)
      @result[key]
    end

    def to_hash
      @result.dup
    end

    private

    def multi_value?(key)
      Array(@options[:multi_value]).include?(key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nagios_parser-1.3.0 lib/nagios_parser/result.rb