Class: EnhancedPrompt::Prompt::Token::User
- Inherits:
-
Object
- Object
- EnhancedPrompt::Prompt::Token::User
- Defined in:
- lib/enhanced_prompt/token/user.rb
Instance Method Summary collapse
- #gid ⇒ Object
- #groupname ⇒ Object
- #login_count ⇒ Object
- #my_login_count ⇒ Object
- #other_login_count ⇒ Object
- #other_usernames ⇒ Object
- #other_users_count ⇒ Object
- #uid ⇒ Object
-
#username ⇒ Object
Shows your username.
-
#usernames ⇒ Object
Shows usernames currently in your system.
- #users_count ⇒ Object
Instance Method Details
#gid ⇒ Object
48 49 50 |
# File 'lib/enhanced_prompt/token/user.rb', line 48 def gid @gid = _passwd.gid end |
#groupname ⇒ Object
40 41 42 |
# File 'lib/enhanced_prompt/token/user.rb', line 40 def groupname @groupname = _group.name end |
#login_count ⇒ Object
28 29 30 |
# File 'lib/enhanced_prompt/token/user.rb', line 28 def login_count @login_count ||= _user_list.size end |
#my_login_count ⇒ Object
32 33 34 |
# File 'lib/enhanced_prompt/token/user.rb', line 32 def my_login_count @my_login_count ||= _user_list.count{|user| user == username} end |
#other_login_count ⇒ Object
36 37 38 |
# File 'lib/enhanced_prompt/token/user.rb', line 36 def other_login_count @other_login_count ||= login_count - my_login_count end |
#other_usernames ⇒ Object
16 17 18 |
# File 'lib/enhanced_prompt/token/user.rb', line 16 def other_usernames @other_user_names ||= usernames - [username] end |
#other_users_count ⇒ Object
24 25 26 |
# File 'lib/enhanced_prompt/token/user.rb', line 24 def other_users_count @other_users_count ||= users_count - 1 end |
#uid ⇒ Object
44 45 46 |
# File 'lib/enhanced_prompt/token/user.rb', line 44 def uid @uid = _passwd.uid end |
#username ⇒ Object
Shows your username
7 8 9 |
# File 'lib/enhanced_prompt/token/user.rb', line 7 def username @username ||= ENV['USER'] || ENV['LOGNAME'] || Etc.getlogin end |
#usernames ⇒ Object
Shows usernames currently in your system
12 13 14 |
# File 'lib/enhanced_prompt/token/user.rb', line 12 def usernames @user_names ||= _user_list.uniq end |
#users_count ⇒ Object
20 21 22 |
# File 'lib/enhanced_prompt/token/user.rb', line 20 def users_count @users_count ||= usernames.size end |