Class: Pkgr::Env

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variables = nil) ⇒ Env

Returns a new instance of Env.



5
6
7
# File 'lib/pkgr/env.rb', line 5

def initialize(variables = nil)
  @variables = variables || []
end

Instance Attribute Details

#variablesObject (readonly)

Returns the value of attribute variables.



3
4
5
# File 'lib/pkgr/env.rb', line 3

def variables
  @variables
end

Instance Method Details

#merge(other) ⇒ Object



21
22
23
# File 'lib/pkgr/env.rb', line 21

def merge(other)
  self.class.new(self.variables + other.variables)
end

#present?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/pkgr/env.rb', line 13

def present?
  create_env_hash_from_string.length > 0
end

#to_hashObject



17
18
19
# File 'lib/pkgr/env.rb', line 17

def to_hash
  create_env_hash_from_string
end

#to_sObject



9
10
11
# File 'lib/pkgr/env.rb', line 9

def to_s
  to_hash.map {|k, v| " #{k}=#{v}" }.join
end