class GodObject::FilePermissions::SpecialMode
Represents one component of the normal file mode in POSIX environments.
The SpecialMode
is basically an immutable bit set consisting of the digits :setuid, :setgid and :sticky.
Constants
- BIT_SET_CONFIGURATION
Configuration for the GodObject:::BitSet object which is used to handle the state internally.
- PATTERN
Regular expression for parsing a
SpecialMode
from a String representation.
Public Class Methods
new(*mode_components)
click to toggle source
Initializes a new SpecialMode
@return [void]
@overload initialize(numeric)
@param [Integer] numeric a numeric representation
@overload initialize(enabled_digits)
@param [Array<:setuid, :setgid, :sticky>] enabled_digits a list of enabled digits
# File lib/god_object/file_permissions/special_mode.rb, line 88 def initialize(*mode_components) @bit_set = BIT_SET_CONFIGURATION.new(*mode_components) end
parse(string)
click to toggle source
Creates a new SpecialMode
object by parsing a String representation.
@param [String] string a String containing a mode @return [GodObject::FilePermissions::SpecialMode] a new SpecialMode
object
# File lib/god_object/file_permissions/special_mode.rb, line 58 def parse(string) result = string.match(PATTERN) case when !result raise ParserError, 'Invalid format' when result[:octal_mode] new(result[:octal_mode].to_i) else mode_components = [] mode_components << :setuid if result[:digit_mode][0] == 's' mode_components << :setgid if result[:digit_mode][1] == 's' mode_components << :sticky if result[:digit_mode][2] == 't' new(mode_components) end end