Document User.
This commit is contained in:
parent
d8eb508500
commit
319a288198
@ -5,7 +5,11 @@ require "etc"
|
|||||||
|
|
||||||
require "system_command"
|
require "system_command"
|
||||||
|
|
||||||
|
# A system user.
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
class User < DelegateClass(String)
|
class User < DelegateClass(String)
|
||||||
|
# Return whether the user has an active GUI session.
|
||||||
def gui?
|
def gui?
|
||||||
out, _, status = system_command "who"
|
out, _, status = system_command "who"
|
||||||
return false unless status.success?
|
return false unless status.success?
|
||||||
@ -15,6 +19,7 @@ class User < DelegateClass(String)
|
|||||||
.any? { |user, type,| user == self && type == "console" }
|
.any? { |user, type,| user == self && type == "console" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return the current user.
|
||||||
def self.current
|
def self.current
|
||||||
return @current if defined?(@current)
|
return @current if defined?(@current)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user