Sha256: c1b412feb21003cad241a6d9327374776bf01886c70e892992506ae909e1c288

Contents?: true

Size: 523 Bytes

Versions: 10

Compression:

Stored size: 523 Bytes

Contents

# encoding: utf-8
require 'cgi'

module RubyAMI
  class AsyncAGIEnvironmentParser
    def initialize(environment_string)
      @environment_string = environment_string.dup
    end

    def to_hash
      to_array.inject({}) do |accumulator, element|
        accumulator[element[0].to_sym] = element[1] || ''
        accumulator
      end
    end

    def to_s
      @environment_string.dup
    end

    private

    def to_array
      CGI.unescape(@environment_string).split("\n").map { |p| p.split ': ' }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby_ami-2.1.0 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-1.3.4 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-2.0.0 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-1.3.3 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-1.3.2 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-1.3.1 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-1.3.0 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-1.2.6 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-1.2.5 lib/ruby_ami/async_agi_environment_parser.rb
ruby_ami-1.2.4 lib/ruby_ami/async_agi_environment_parser.rb