class DataMetaXtra::FileSys::PosixPerms

POSIX access perms - per system, user, group and world

@!attribute [rw] s

@return [Perm] Sticky flag

@!attribute [rw] u

@return [Perm] user perms

@!attribute [rw] g

@return [Perm] group perms

@!attribute [rw] a

@return [Perm] world perms (all)

Attributes

a[RW]
g[RW]
s[RW]
u[RW]

Public Class Methods

from(source, kind) click to toggle source

Parses the {Perm} instance from the given source.

@param [String] source either a String or a Fixnum a {Perm} or nil, see the method {Perm.of} for details. @param [String] kind the kind of the permissions for diagnostics, like 'user', 'group', 'world' or 'system' @return [Perm] instance according to the description @raise [ArgumentError] if the specs contain invalid character in case of a String or if the source is neither

a String nor a {Perm} nor +nil+
# File lib/dataMetaXtra/fileSys.rb, line 205
def self.from(source, kind)
    case
        when source.kind_of?(NilClass) || source.kind_of?(Perm)
            source
        when source.kind_of?(String) || source.kind_of?(Fixnum)
            Perm.of(source)
        else
            raise ArgumentError, %<For #{kind} perms, invalid perm source: #{source.inspect} >
    end
end
new(user, group, world, sys = nil) click to toggle source

Creates an instance @param [String] user user permissions, can be passed as {Perm} object or String or Fixnum, see the method {PosixPerms.from} for details. @param [String] group group permissions, can be passed as {Perm} object or String or Fixnum, see the method {PosixPerms.from} for details. @param [String] world world permissions, can be passed as {Perm} object or String or Fixnum, see the method {PosixPerms.from} for details. @param [String] sys system permissions, can be passed as {Perm} object or String or Fixnum, see the method {PosixPerms.from} for details.

# File lib/dataMetaXtra/fileSys.rb, line 223
def initialize(user, group, world, sys = nil)
    @u = PosixPerms.from(user, 'user')
    @g = PosixPerms.from(group, 'group')
    @a = PosixPerms.from(world, 'world')
    @s = PosixPerms.from(sys, 'system')
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 240
def ==(other)
    self.u == other.u && self.g == other.g && self.a == other.a && self.s == other.s
end
eql?(other) click to toggle source

Standard Ruby object equality method for hashes and sets.

# File lib/dataMetaXtra/fileSys.rb, line 233
def eql?(other)
    self.u == other.u && self.g == other.g && self.a == other.a && self.s == other.s
end
to_i() click to toggle source

Converts to integer POSIX specification, 3 bits per each of User, Group, All aka World aka Others

# File lib/dataMetaXtra/fileSys.rb, line 247
def to_i; ('%d%d%d' % [@u, @g, @a]).to_i(8) end