Class: RubyAMI::AsyncAGIEnvironmentParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_ami/async_agi_environment_parser.rb

Constant Summary collapse

NEWLINE =
"%0A".freeze
COLON_SPACE =
'%3A%20'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(environment_string) ⇒ AsyncAGIEnvironmentParser

Returns a new instance of AsyncAGIEnvironmentParser.



9
10
11
# File 'lib/ruby_ami/async_agi_environment_parser.rb', line 9

def initialize(environment_string)
  @environment_string = environment_string.dup
end

Instance Method Details

#to_hashObject



13
14
15
16
17
18
# File 'lib/ruby_ami/async_agi_environment_parser.rb', line 13

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

#to_sObject



20
21
22
# File 'lib/ruby_ami/async_agi_environment_parser.rb', line 20

def to_s
  @environment_string.dup
end