class OodSupport::Group

A helper object describing a Unix group's details

Attributes

id[R]

The id of the group @return [Integer] the group id

name[R]

The name of the group @return [String] the group name

Public Class Methods

new(group = Process.group) click to toggle source

@param group [Integer, to_s] the group id or name

# File lib/ood_support/group.rb, line 17
def initialize(group = Process.group)
  if group.is_a?(Integer)
    @id = group
    @name = Etc.getgrgid(@id).name
  else
    @name = group.to_s
    @id = Etc.getgrnam(@name).gid
  end
end

Public Instance Methods

<=>(other) click to toggle source

The comparison operator for sorting values @param other [#to_s] group to compare against @return [Integer] how groups compare

# File lib/ood_support/group.rb, line 30
def <=>(other)
  name <=> other
end
eql?(other) click to toggle source

Checks whether two Group objects have the same group as well as that the object is in the Group class @param other [Group] group to compare against @return [Boolean] whether same objects

# File lib/ood_support/group.rb, line 38
def eql?(other)
  self.class == other.class && self == other
end
hash() click to toggle source

Generates a hash value for this object @return [Integer] hash value of object

# File lib/ood_support/group.rb, line 44
def hash
  [self.class, name].hash
end
to_s() click to toggle source

Convert object to string using group name as string value @return [String] the group name

# File lib/ood_support/group.rb, line 50
def to_s
  name
end