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
Public Class Methods
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
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
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
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