Sha256: 89f1e4084fc4842d6278e7800651599567149f5cceabb5f1bd75a7aaaad059ca
Contents?: true
Size: 604 Bytes
Versions: 6
Compression:
Stored size: 604 Bytes
Contents
class Module # Returns the root name of the module/class. # # module Example # class Demo # end # end # # Demo.name #=> "Example::Demo" # Demo.basename #=> "Demo" # # For anonymous modules this will provide a basename # based on Module#inspect. # # m = Module.new # m.inspect #=> "#<Module:0xb7bb0434>" # m.basename #=> "Module_0xb7bb0434" # # CREDIT: Trans def basename if name and not name.empty? name.gsub(/^.*::/, '') else nil #inspect.gsub('#<','').gsub('>','').sub(':', '_') end end end
Version data entries
6 entries across 6 versions & 2 rubygems