Class: Class

Inherits:
Object show all
Defined in:
lib/rltk/util/monkeys.rb

Overview

Monkey-patched Class class.

Instance Method Summary collapse

Instance Method Details

#includes_module?(mod) ⇒ Boolean

Checks for module inclusion.

Parameters:

  • mod (Module)

    Module to check the inclusion of.

Returns:

  • (Boolean)


84
85
86
# File 'lib/rltk/util/monkeys.rb', line 84

def includes_module?(mod)
	self.included_modules.include?(mod)
end

#short_nameString

Returns Name of class without the namespace.

Returns:

  • (String)

    Name of class without the namespace.



89
90
91
# File 'lib/rltk/util/monkeys.rb', line 89

def short_name
	self.name.split('::').last
end

#subclass_of?(klass) ⇒ Boolean

Checks to see if a Class object is a subclass of the given class.

Parameters:

  • klass (Class)

    Class we are checking if this is a subclass of.

Returns:

  • (Boolean)


96
97
98
99
100
101
102
103
104
# File 'lib/rltk/util/monkeys.rb', line 96

def subclass_of?(klass)
	raise 'The klass parameter must be an instance of Class.' if not klass.is_a?(Class)
	
	if (superklass = self.superclass)
		superklass == klass or superklass.subclass_of?(klass)
	else
		false
	end
end