Class: TestForRoot::User
- Inherits:
-
Object
- Object
- TestForRoot::User
- Defined in:
- lib/test_for_root/user.rb
Instance Attribute Summary collapse
-
#member_of ⇒ Object
readonly
Returns the value of attribute member_of.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #groups ⇒ Object
-
#initialize ⇒ User
constructor
A new instance of User.
- #member?(group_name) ⇒ Boolean
- #name ⇒ Object
- #uid ⇒ Object
Constructor Details
#initialize ⇒ User
Returns a new instance of User.
6 7 8 9 10 |
# File 'lib/test_for_root/user.rb', line 6 def initialize @user = `id -un`.chomp @member_of = (`groups #{@user}`.chomp.split(":"))[1].split @user_id = %x{id -u}.chomp.to_i end |
Instance Attribute Details
#member_of ⇒ Object (readonly)
Returns the value of attribute member_of.
4 5 6 |
# File 'lib/test_for_root/user.rb', line 4 def member_of @member_of end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/test_for_root/user.rb', line 4 def user @user end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
4 5 6 |
# File 'lib/test_for_root/user.rb', line 4 def user_id @user_id end |
Instance Method Details
#groups ⇒ Object
16 17 18 |
# File 'lib/test_for_root/user.rb', line 16 def groups @member_of end |
#member?(group_name) ⇒ Boolean
20 21 22 |
# File 'lib/test_for_root/user.rb', line 20 def member? (group_name) @member_of.include? group_name end |
#name ⇒ Object
12 13 14 |
# File 'lib/test_for_root/user.rb', line 12 def name @user end |
#uid ⇒ Object
24 25 26 |
# File 'lib/test_for_root/user.rb', line 24 def uid @user_id end |