Module: ComputeUnit::Utils

Included in:
Device
Defined in:
lib/compute_unit/utils.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.check_for_rootBoolean

Returns - returns true if user is root.

Returns:

  • (Boolean)
    • returns true if user is root

Raises:



19
20
21
22
23
# File 'lib/compute_unit/utils.rb', line 19

def check_for_root
  raise Exceptions::NoPermission.new('Please run this command as root or with sudo') unless root?

  root?
end

.root?Boolean

Returns - return true if the current user is root.

Returns:

  • (Boolean)
    • return true if the current user is root



8
9
10
# File 'lib/compute_unit/utils.rb', line 8

def self.root?
  ::Etc.getpwuid.name == 'root'
end

Instance Method Details

#root?Boolean

Returns - return true if the current user is root.

Returns:

  • (Boolean)
    • return true if the current user is root



13
14
15
# File 'lib/compute_unit/utils.rb', line 13

def root?
  ::Etc.getpwuid.name == 'root'
end