Class: Module
- Defined in:
- ext/enterprise_script_service/mruby/mrblib/00class.rb,
ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/mrblib/module.rb
Instance Method Summary collapse
-
#<(other) ⇒ Object
call-seq: mod < other -> true, false, or nil.
-
#<=(other) ⇒ Object
call-seq: mod <= other -> true, false, or nil.
-
#<=>(other) ⇒ Object
call-seq: module <=> other_module -> -1, 0, +1, or nil.
-
#>(other) ⇒ Object
call-seq: mod > other -> true, false, or nil.
-
#>=(other) ⇒ Object
call-seq: mod >= other -> true, false, or nil.
-
#attr_accessor(*names) ⇒ Object
15.2.2.4.12.
-
#include(*args) ⇒ Object
15.2.2.4.27.
- #prepend(*args) ⇒ Object
Instance Method Details
#<(other) ⇒ Object
call-seq:
mod < other -> true, false, or nil
Returns true if mod is a subclass of other. Returns nil if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A < B” implies “A < B”.)
12 13 14 15 16 17 18 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/mrblib/module.rb', line 12 def <(other) if self.equal?(other) false else self <= other end end |
#<=(other) ⇒ Object
call-seq:
mod <= other -> true, false, or nil
Returns true if mod is a subclass of other or is the same as other. Returns nil if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A < B” implies “A < B”.)
29 30 31 32 33 34 35 36 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/mrblib/module.rb', line 29 def <=(other) raise TypeError, 'compared with non class/module' unless other.is_a?(Module) if self.ancestors.include?(other) return true elsif other.ancestors.include?(self) return false end end |
#<=>(other) ⇒ Object
call-seq:
module <=> other_module -> -1, 0, +1, or nil
Comparison—Returns -1, 0, +1 or nil depending on whether module includes other_module, they are the same, or if module is included by other_module.
Returns nil if module has no relationship with other_module, if other_module is not a module, or if the two values are incomparable.
81 82 83 84 85 86 87 88 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/mrblib/module.rb', line 81 def <=>(other) return 0 if self.equal?(other) return nil unless other.is_a?(Module) cmp = self < other return -1 if cmp return 1 unless cmp.nil? return nil end |
#>(other) ⇒ Object
call-seq:
mod > other -> true, false, or nil
Returns true if mod is an ancestor of other. Returns nil if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A < B” implies “B > A”.)
47 48 49 50 51 52 53 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/mrblib/module.rb', line 47 def >(other) if self.equal?(other) false else self >= other end end |
#>=(other) ⇒ Object
call-seq:
mod >= other -> true, false, or nil
Returns true if mod is an ancestor of other, or the two modules are the same. Returns nil if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A < B” implies “B > A”.)
65 66 67 68 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/mrblib/module.rb', line 65 def >=(other) raise TypeError, 'compared with non class/module' unless other.is_a?(Module) return other < self end |
#attr_accessor(*names) ⇒ Object
15.2.2.4.12
13 14 15 16 |
# File 'ext/enterprise_script_service/mruby/mrblib/00class.rb', line 13 def attr_accessor(*names) attr_reader(*names) attr_writer(*names) end |
#include(*args) ⇒ Object
15.2.2.4.27
24 25 26 27 28 29 30 |
# File 'ext/enterprise_script_service/mruby/mrblib/00class.rb', line 24 def include(*args) args.reverse.each do |m| m.append_features(self) m.included(self) end self end |
#prepend(*args) ⇒ Object
32 33 34 35 36 37 38 |
# File 'ext/enterprise_script_service/mruby/mrblib/00class.rb', line 32 def prepend(*args) args.reverse.each do |m| m.prepend_features(self) m.prepended(self) end self end |