Class: AutomateIt::AccountManager::Etc::UserQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/automateit/account_manager/etc.rb

Overview

UserQuery

A class used for querying users. See AccountManager#users.

Instance Method Summary collapse

Instance Method Details

#[](query) ⇒ Object

See AccountManager#users



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/automateit/account_manager/etc.rb', line 28

def [](query)
  ::Etc.endpwent
  begin
    case query
    when String
      return ::Etc.getpwnam(query)
    when Fixnum
      return ::Etc.getpwuid(query)
    else
      raise TypeError.new("unknonwn type for query: #{query.class}")
    end
  rescue ArgumentError
    return nil
  end
end