Class: Kanrisuru::Remote::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/kanrisuru/remote/env.rb

Instance Method Summary collapse

Constructor Details

#initializeEnv

Returns a new instance of Env.



6
7
8
# File 'lib/kanrisuru/remote/env.rb', line 6

def initialize
  @env = {}
end

Instance Method Details

#[](key) ⇒ Object



36
37
38
# File 'lib/kanrisuru/remote/env.rb', line 36

def [](key)
  @env[key.to_s.upcase]
end

#[]=(key, value) ⇒ Object



40
41
42
# File 'lib/kanrisuru/remote/env.rb', line 40

def []=(key, value)
  @env[key.to_s.upcase] = value
end

#clearObject



14
15
16
# File 'lib/kanrisuru/remote/env.rb', line 14

def clear
  @env = {}
end

#countObject



28
29
30
# File 'lib/kanrisuru/remote/env.rb', line 28

def count
  @env.count
end

#delete(key) ⇒ Object



32
33
34
# File 'lib/kanrisuru/remote/env.rb', line 32

def delete(key)
  @env.delete(key.to_s.upcase)
end

#to_hObject



10
11
12
# File 'lib/kanrisuru/remote/env.rb', line 10

def to_h
  @env
end

#to_sObject



18
19
20
21
22
23
24
25
26
# File 'lib/kanrisuru/remote/env.rb', line 18

def to_s
  string = ''
  @env.each.with_index do |(key, value), index|
    string += "export #{key}=#{value};"
    string += ' ' if index < @env.length - 1
  end

  string
end