Method: BBLib.namespace_of

Defined in:
lib/bblib/core/util/object.rb

.namespace_of(klass) ⇒ Object

Returns the encapsulating object space of a given class. Ex: For a class called BBLib::String, this method will return BBLib as the namespace. Ex2: For a class BBLib::String::Char, this method will return BBLib::String as the namespace.



76
77
78
79
80
# File 'lib/bblib/core/util/object.rb', line 76

def self.namespace_of(klass)
  split = klass.to_s.split('::')
  return klass if split.size == 1
  Object.const_get(split[0..-2].join('::'))
end