Class: OodSupport::User
- Inherits:
-
Object
- Object
- OodSupport::User
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/ood_support/user.rb
Overview
A helper object used to query information about a system user from the local host
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
The comparison operator for sorting values.
-
#dir ⇒ String
(also: #home)
The user’s home directory.
-
#eql?(other) ⇒ Boolean
Checks whether two User objects have the same user as well as that the object is in the User class.
-
#gecos ⇒ String
The user’s real name.
-
#group ⇒ Group
Provide primary group of user.
-
#groups ⇒ Array<Group>
List of all groups that user belongs to.
-
#hash ⇒ Integer
Generates a hash value for this object.
-
#in_group?(group) ⇒ Boolean
(also: #member_of_group?)
Determine whether user is part of specified group.
-
#initialize(user = Process.user) ⇒ User
constructor
A new instance of User.
-
#name ⇒ String
The user name.
-
#shell ⇒ String
The user’s shell.
-
#to_s ⇒ String
Convert object to string using user name as string value.
-
#uid ⇒ Integer
(also: #id)
The user’s id.
Constructor Details
Instance Method Details
#<=>(other) ⇒ Integer
The comparison operator for sorting values
62 63 64 |
# File 'lib/ood_support/user.rb', line 62 def <=>(other) name <=> other end |
#dir ⇒ String Also known as: home
The user’s home directory
27 |
# File 'lib/ood_support/user.rb', line 27 delegate [:name, :uid, :gecos, :dir, :shell] => :@passwd |
#eql?(other) ⇒ Boolean
Checks whether two User objects have the same user as well as that the object is in the User class
70 71 72 |
# File 'lib/ood_support/user.rb', line 70 def eql?(other) self.class == other.class && self == other end |
#gecos ⇒ String
The user’s real name
27 |
# File 'lib/ood_support/user.rb', line 27 delegate [:name, :uid, :gecos, :dir, :shell] => :@passwd |
#group ⇒ Group
Provide primary group of user
49 50 51 |
# File 'lib/ood_support/user.rb', line 49 def group groups.first end |
#groups ⇒ Array<Group>
List of all groups that user belongs to
55 56 57 |
# File 'lib/ood_support/user.rb', line 55 def groups @groups ||= get_groups end |
#hash ⇒ Integer
Generates a hash value for this object
76 77 78 |
# File 'lib/ood_support/user.rb', line 76 def hash [self.class, name].hash end |
#in_group?(group) ⇒ Boolean Also known as: member_of_group?
Determine whether user is part of specified group
41 42 43 |
# File 'lib/ood_support/user.rb', line 41 def in_group?(group) groups.include? Group.new(group) end |
#name ⇒ String
The user name
27 |
# File 'lib/ood_support/user.rb', line 27 delegate [:name, :uid, :gecos, :dir, :shell] => :@passwd |
#shell ⇒ String
The user’s shell
27 |
# File 'lib/ood_support/user.rb', line 27 delegate [:name, :uid, :gecos, :dir, :shell] => :@passwd |
#to_s ⇒ String
Convert object to string using user name as string value
82 83 84 |
# File 'lib/ood_support/user.rb', line 82 def to_s name end |
#uid ⇒ Integer Also known as: id
The user’s id
27 |
# File 'lib/ood_support/user.rb', line 27 delegate [:name, :uid, :gecos, :dir, :shell] => :@passwd |