Class: AutomateIt::AccountManager::Etc::GroupQuery

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

Overview

GroupQuery

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

Instance Method Summary collapse

Instance Method Details

#[](query) ⇒ Object

See AccountManager#groups



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/automateit/account_manager/etc.rb', line 62

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