Module: GodObject::FilePermissions::ModeMixin
- Included in:
- Mode, SpecialMode
- Defined in:
- lib/god_object/file_permissions/mode_mixin.rb
Overview
Common functionality of both Mode and SpecialMode
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#+(other) ⇒ GodObject::FilePermissions::ModeMixin
A new Mode with the enabled digits of the current and other.
-
#<=>(other) ⇒ -1, ...
Compares the Mode to another to determine its relative position.
-
#difference(other) ⇒ GodObject::FilePermissions::ModeMixin
(also: #-)
A new Mode with the enabled digits of the current without the enabled digits of other.
-
#eql?(other) ⇒ true, false
Answers if another object is equal and of the same type family.
-
#inspect ⇒ String
Represents a Mode as String for debugging.
-
#intersection(other) ⇒ GodObject::FilePermissions::ModeMixin
(also: #&)
A new Mode with only those digits enabled which are enabled in both the current and other.
-
#invert ⇒ GodObject::FilePermissions::ModeMixin
A new Mode with all digit states inverted.
-
#symmetric_difference(other) ⇒ GodObject::FilePermissions::ModeMixin
(also: #^)
A new Mode with the enabled digits which are enabled in only one of current and other.
-
#union(other) ⇒ GodObject::FilePermissions::ModeMixin
(also: #|)
A new Mode with the enabled digits of the current and other.
Instance Method Details
#+(other) ⇒ GodObject::FilePermissions::ModeMixin
Returns a new Mode with the enabled digits of the current and other.
74 75 76 77 78 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 74 def +(other) other = other.enabled_digits if other.respond_to?(:enabled_digits) self.class.new(enabled_digits + other) end |
#<=>(other) ⇒ -1, ...
Only other Modes or Integer-likes are considered comparable.
Compares the Mode to another to determine its relative position.
Relative position is defined by comparing the Integer representation.
138 139 140 141 142 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 138 def <=>(other) to_i <=> other.to_i rescue NoMethodError nil end |
#difference(other) ⇒ GodObject::FilePermissions::ModeMixin Also known as: -
Returns a new Mode with the enabled digits of the current without the enabled digits of other.
96 97 98 99 100 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 96 def difference(other) other = other.enabled_digits if other.respond_to?(:enabled_digits) self.class.new(enabled_digits - other) end |
#eql?(other) ⇒ true, false
Answers if another object is equal and of the same type family.
150 151 152 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 150 def eql?(other) self == other && other.kind_of?(self.class) end |
#inspect ⇒ String
Represents a Mode as String for debugging.
157 158 159 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 157 def inspect "#<#{self.class}: #{to_s.inspect}>" end |
#intersection(other) ⇒ GodObject::FilePermissions::ModeMixin Also known as: &
Returns a new Mode with only those digits enabled which are enabled in both the current and other.
108 109 110 111 112 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 108 def intersection(other) other = other.to_i if other.respond_to?(:to_i) self.class.new(to_i & other) end |
#invert ⇒ GodObject::FilePermissions::ModeMixin
Returns a new Mode with all digit states inverted.
66 67 68 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 66 def invert self.class.new(disabled_digits) end |
#symmetric_difference(other) ⇒ GodObject::FilePermissions::ModeMixin Also known as: ^
Returns a new Mode with the enabled digits which are enabled in only one of current and other.
120 121 122 123 124 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 120 def symmetric_difference(other) other = other.to_i if other.respond_to?(:to_i) self.class.new(to_i ^ other) end |
#union(other) ⇒ GodObject::FilePermissions::ModeMixin Also known as: |
Returns a new Mode with the enabled digits of the current and other.
84 85 86 87 88 |
# File 'lib/god_object/file_permissions/mode_mixin.rb', line 84 def union(other) other = other.to_i if other.respond_to?(:to_i) self.class.new(to_i | other) end |