Module: SleepingKingStudios::Tools::Toolbox::HeritableData::ClassMethods
- Defined in:
- lib/sleeping_king_studios/tools/toolbox/heritable_data.rb
Overview
Methods prepended onto the singleton class when including HeritableData.
Instance Method Summary collapse
-
#<(other) ⇒ true, ...
Compares ‘self` and `other`.
-
#<=(other) ⇒ true, ...
Compares ‘self` and `other`.
-
#<=>(other) ⇒ -1, ...
Compares ‘self` and `other`.
-
#===(object) ⇒ true
If the object is an instance of the data class, or if the object is an instance of a Data class that inherits members and methods from self.
-
#>(other) ⇒ true, ...
Compares ‘self` and `other`.
-
#>=(other) ⇒ true, ...
Compares ‘self` and `other`.
-
#define(*symbols) { ... } ⇒ Object
Defines a new Data class including the members/methods of this class.
Instance Method Details
#<(other) ⇒ true, ...
Compares ‘self` and `other`.
20 21 22 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 20 def <(other) (self <=> other)&.then { |cmp| cmp == -1 } end |
#<=(other) ⇒ true, ...
Compares ‘self` and `other`.
34 35 36 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 34 def <=(other) (self <=> other)&.then { |cmp| cmp < 1 } end |
#<=>(other) ⇒ -1, ...
Compares ‘self` and `other`.
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 48 def <=>(other) return super unless other.is_a?(Class) return -1 if other.equal?(Data) return 0 if other.equal?(self) return nil unless other.const_defined?(:HeritableMethods) return -1 if include?(other::HeritableMethods) return 1 if other.include?(self::HeritableMethods) nil end |
#===(object) ⇒ true
Returns if the object is an instance of the data class, or if the object is an instance of a Data class that inherits members and methods from self.
65 66 67 68 69 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 65 def ===(object) return true if super (self > object.class) || false end |
#>(other) ⇒ true, ...
Compares ‘self` and `other`.
81 82 83 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 81 def >(other) (self <=> other)&.then { |cmp| cmp == 1 } end |
#>=(other) ⇒ true, ...
Compares ‘self` and `other`.
95 96 97 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 95 def >=(other) (self <=> other)&.then { |cmp| cmp > -1 } end |
#define(*symbols) { ... } ⇒ Object
Defines a new Data class including the members/methods of this class.
The defined data class will include HeritableData, and will be able to define it’s own Data types using this method.
109 110 111 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 109 def define(*symbols, &) HeritableData.define(*symbols, parent_class: self, &) end |