Class: Rubyfox::Server::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyfox/server/environment.rb

Instance Method Summary collapse

Constructor Details

#initialize(env, asker) ⇒ Environment

Returns a new instance of Environment.



4
5
6
7
8
# File 'lib/rubyfox/server/environment.rb', line 4

def initialize(env, asker)
  @env    = env
  @asker  = asker
  @local  = {}
end

Instance Method Details

#[](name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubyfox/server/environment.rb', line 10

def [](name)
  name = name.to_s
  value = @local[name] || @env[name]
  value || begin
    msg = "Specify env #{name}:"
    loop do
      answer = @asker.ask(msg)
      unless answer.empty?
        self[name] = answer
        break answer
      end
    end
  end
end

#[]=(name, value) ⇒ Object



25
26
27
# File 'lib/rubyfox/server/environment.rb', line 25

def []=(name, value)
  @local[name.to_s] = value
end