Class: User Private

Inherits:
SimpleDelegator
  • Object
show all
Extended by:
T::Sig
Includes:
SystemCommand::Mixin
Defined in:
Library/Homebrew/utils/user.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A system user.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Class Method Details

.currentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


30
31
32
33
34
35
36
37
# File 'Library/Homebrew/utils/user.rb', line 30

def self.current
  return @current if defined?(@current)

  pwuid = Etc.getpwuid(Process.euid)
  return if pwuid.nil?

  @current = new(pwuid.name)
end

Instance Method Details

#gui?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

19
20
21
22
23
24
25
26
# File 'Library/Homebrew/utils/user.rb', line 19

def gui?
  out, _, status = system_command "who"
  return false unless status.success?

  out.lines
     .map(&:split)
     .any? { |user, type,| user == self && type == "console" }
end