Class: Snackhack2::ListUsers
- Inherits:
-
Object
- Object
- Snackhack2::ListUsers
- Defined in:
- lib/snackhack2/list_users.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #auto ⇒ Object
-
#initialize(user) ⇒ ListUsers
constructor
A new instance of ListUsers.
- #linux ⇒ Object
- #windows ⇒ Object
- #windows_search_user ⇒ Object
Constructor Details
#initialize(user) ⇒ ListUsers
Returns a new instance of ListUsers.
7 8 9 |
# File 'lib/snackhack2/list_users.rb', line 7 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
5 6 7 |
# File 'lib/snackhack2/list_users.rb', line 5 def user @user end |
Instance Method Details
#auto ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/snackhack2/list_users.rb', line 25 def auto os = RUBY_PLATFORM if os.match?('linux') linux elsif os.match?('mingw') || os.match?(/mswin|msys|mingw|cygwin|bccwin|wince|emc/) windows end end |
#linux ⇒ Object
11 12 13 14 15 |
# File 'lib/snackhack2/list_users.rb', line 11 def linux `cat /etc/passwd`.split("\n").each do |l| puts l.split(':')[0] end end |
#windows ⇒ Object
17 18 19 |
# File 'lib/snackhack2/list_users.rb', line 17 def windows puts `net users` end |
#windows_search_user ⇒ Object
21 22 23 |
# File 'lib/snackhack2/list_users.rb', line 21 def windows_search_user puts `net user #{@user}` end |