Class: Environment

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

Class Method Summary collapse

Class Method Details

.homeObject



2
3
4
5
6
7
8
9
10
# File 'lib/environment.rb', line 2

def self.home 
  ["USERPROFILE","HOME"].each {|v|
    return ENV[v].gsub('\\','/') unless ENV[v].nil?
  }
  dir="~"
  dir=ENV["HOME"] unless ENV["HOME"].nil?
  dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
  return dir
end

.machineObject



12
13
14
15
16
17
18
19
20
# File 'lib/environment.rb', line 12

def self.machine
   if !ENV['COMPUTERNAME'].nil? 
  return ENV['COMPUTERNAME']
end

   machine = `hostname`
   machine = machine.split('.')[0] if machine.include?('.')
return machine.strip
end

.userObject



22
23
24
25
# File 'lib/environment.rb', line 22

def self.user
	return ENV['USER'] if !ENV['USER'].nil?  #on Unix
  ENV['USERNAME']
end