Class: Quark::Quark::Os::Environment

Inherits:
DatawireQuarkCore::QuarkObject show all
Extended by:
DatawireQuarkCore::Static
Defined in:
lib/quark/os.rb

Overview

Class for interacting with the process environment

Constant Summary

Constants included from DatawireQuarkCore::Static

DatawireQuarkCore::Static::Unassigned

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DatawireQuarkCore::Static

_lazy_statics, static, unlazy_statics

Methods inherited from DatawireQuarkCore::QuarkObject

#to_s

Constructor Details

#initializeEnvironment

Returns a new instance of Environment.



193
194
195
196
197
# File 'lib/quark/os.rb', line 193

def initialize()
    self.__init_fields__

    nil
end

Class Method Details

.getEnvironmentObject

Retrieve the Environment singleton



205
206
207
208
209
210
# File 'lib/quark/os.rb', line 205

def self.getEnvironment()
    
    return ::Quark.quark.os.Environment.ENV

    nil
end

.getUserObject

Fetch the value of $USER



241
242
243
244
245
246
# File 'lib/quark/os.rb', line 241

def self.getUser()
    
    return ENV["USER"]

    nil
end

Instance Method Details

#__get__(key) ⇒ Object

Fetch the value of an environment variable. Returns null if the variable is not set.



216
217
218
219
220
221
# File 'lib/quark/os.rb', line 216

def __get__(key)
    
    return ENV[key]

    nil
end

#__init_fields__Object



274
275
276
277
278
# File 'lib/quark/os.rb', line 274

def __init_fields__()
    

    nil
end

#_getClassObject



248
249
250
251
252
253
# File 'lib/quark/os.rb', line 248

def _getClass()
    
    return "quark.os.Environment"

    nil
end

#_getField(name) ⇒ Object



255
256
257
258
259
260
261
262
263
# File 'lib/quark/os.rb', line 255

def _getField(name)
    
    if ((name) == ("ENV"))
        return ::Quark.quark.os.Environment.ENV
    end
    return nil

    nil
end

#_setField(name, value) ⇒ Object



265
266
267
268
269
270
271
272
# File 'lib/quark/os.rb', line 265

def _setField(name, value)
    
    if ((name) == ("ENV"))
        ::Quark.quark.os.Environment.ENV = ::DatawireQuarkCore.cast(value) { ::Quark.quark.os.Environment }
    end

    nil
end

#get(key, default_value) ⇒ Object

Fetch the value of an environment variable. Returns the specified default if the variable is not set.



227
228
229
230
231
232
233
234
235
236
# File 'lib/quark/os.rb', line 227

def get(key, default_value)
    
    value = ENV[key]
    if ((value) == (nil))
        return default_value
    end
    return value

    nil
end