> For the complete documentation index, see [llms.txt](https://ploegert.gitbook.io/til/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ploegert.gitbook.io/til/programmy/rails/demodulize-a-class-name.md).

# Demodulize A Class Name

If you call `.class.name` on an instance of some class, the fully qualified name will be returned, module names and all. Consider the following example class:

```ruby
module One
  module Two
    class Three
      ...
    end
  end
end
```

```ruby
> One::Two::Three.new.class.name
#=> "One::Two::Three"
```

If you just want the unqualified class name; modules not included, you can use the `#demodulize` method provided by `ActiveSupport`.

```ruby
> One::Two::Three.new.class.name.demodulize
#=> "Three"
```
