class_variable_get

mod.class_variable_get(symbol) â obj Instance Public methods Returns the value of the given class variable (or throws a NameError exception). The @@ part of the variable name should be included for regular class variables class Fred @@foo = 99 end Fred.class_variable_get(:@@foo) #=> 99

class_variable_defined?

obj.class_variable_defined?(symbol) â true or false Instance Public methods Returns true if the given class variable is defined in obj. class Fred @@foo = 99 end Fred.class_variable_defined?(:@@foo) #=> true Fred.class_variable_defined?(:@@bar) #=> false

class_exec

mod.class_exec(arg...) {|var...| block } â obj Instance Public methods Evaluates the given block in the context of the class/module. The method defined in the block will belong to the receiver. class Thing end Thing.class_exec{ def hello() "Hello there!" end } puts Thing.new.hello() produces: Hello there!

class_eval

mod.class_eval(string [, filename [, lineno]]) â obj Instance Public methods Evaluates the string or block in the context of mod, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. module_eval returns the result of evaluating its argument. The optional filename and lineno parameters set the text for error messages. class Thing end a = %q{def hello() "Hello there!" end} Thing.module_eval(a) puts Thing.new.h

autoload?

mod.autoload?(name) â String or nil Instance Public methods Returns filename to be loaded if name is registered as autoload in the namespace of mod. module A end A.autoload(:B, "b") A.autoload?(:B) #=> "b"

autoload

mod.autoload(module, filename) â nil Instance Public methods Registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed in the namespace of mod. module A end A.autoload(:B, "b") A::B.doit # autoloads "b"

ancestors

mod.ancestors â array Instance Public methods Returns a list of modules included in mod (including mod itself). module Mod include Math include Comparable end Mod.ancestors #=> [Mod, Comparable, Math] Math.ancestors #=> [Math]

>=

mod >= other â true, false, or nil Instance Public methods 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â).

&gt;

mod > other â true, false, or nil Instance Public methods 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â).

===

mod === obj â true or false Instance Public methods Case EqualityâReturns true if anObject is an instance of mod or one of mod's descendants. Of limited use for modules, but can be used in case statements to classify objects by class.