Class: QuickAndRuby::Proxy::EnvParser

Inherits:
Object
  • Object
show all
Defined in:
lib/quick_and_ruby/proxy/env_parser.rb

Overview

service parse env for proxy exe

Constant Summary collapse

INDEX_TO_KEY =
{ 3 => :user,
4 => :proxy_host,
5 => :proxy_port }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(env = ENV) ⇒ EnvParser

Returns a new instance of EnvParser.



12
13
14
# File 'lib/quick_and_ruby/proxy/env_parser.rb', line 12

def initialize(env = ENV)
  @env = env
end

Instance Method Details

#parseObject



16
17
18
19
20
21
22
23
# File 'lib/quick_and_ruby/proxy/env_parser.rb', line 16

def parse
  parsed = _parsed_proxy
  return {} unless parsed

  INDEX_TO_KEY.each_with_object({}) do |(index, key), options|
    options[key] = parsed[index] if parsed[index]
  end
end