Class: Module

Inherits:
Object show all
Defined in:
lib/aromat/module.rb

Overview

Monkey-patch Module Class

Instance Method Summary collapse

Instance Method Details

#mod_nameString

Module Name: Returns the name of the Module, without its hierarchical tree.

Returns:

  • (String)

    The name of the Module



10
11
12
# File 'lib/aromat/module.rb', line 10

def mod_name
  name[/[^:]+$/]
end

#mod_parentObject

Parent: Returns the Module’s immediate parent.



22
23
24
25
# File 'lib/aromat/module.rb', line 22

def mod_parent
  n = mod_parent_name
  (n == '') ? nil : const_get(n)
end

#mod_parent_nameObject

Parent Name: Returns the Module’s immediate parent’s name.



16
17
18
# File 'lib/aromat/module.rb', line 16

def mod_parent_name
  name.index('::') ? name.gsub(/::#{mod_name}$/, '') : ''
end