class DataMetaXtra::FileSys::IdName

Generic Id and Name pair, good for any such situation, but in this case used specifically for POSIX user/group ID+Name.

Regarding equality of these instances, it's better to use one of the components straight, although the both the {#eql?} and == method override are provided.

@!attribute [rw] id

@return [Fixnum] numeric ID associated with the name.

@!attribute [rw] name

@return [String] the name associated with the ID

Attributes

id[RW]
name[RW]

Public Class Methods

forName(name) click to toggle source

Name-only instance, id set to nil. Useful for cases when ID is irrelevant, such as transferring directory structure between hosts. @raise [ArgumentError] if the name string is empty or contains invalid characters @param [String] name the {#name}

# File lib/dataMetaXtra/fileSys.rb, line 273
def self.forName(name)
    IdName.new(nil, name)
end
new(id, name) click to toggle source

Convenience constructor @raise [ArgumentError] if the name string is empty or contains invalid characters

# File lib/dataMetaXtra/fileSys.rb, line 281
def initialize(id, name)
    raise ArgumentError, %<Invalid POSIX name: "#{name}"> unless name =~ /^[a-z][\w\.-]*$/
    @id, @name = id, name
end

Public Instance Methods

==(other) click to toggle source

Redefine equality operator for simple comparison, not delegated to {#eql?}, code simply repeated here for speed

# File lib/dataMetaXtra/fileSys.rb, line 296
def ==(other)
    self.id == other.id && self.name == other.name
end
eql?(other) click to toggle source

Standard Ruby object equality method for hashes and sets.

# File lib/dataMetaXtra/fileSys.rb, line 289
def eql?(other)
    self.id == other.id && self.name == other.name
end