# Extract module

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/ruby/2026.3/llms.txt).

> **TL;DR**
> `Refactor | Extract/Introduce | Module`

The Extract Module refactoring allows you to extract certain members from a selected class into a separate module.

To extract a module:

Procedure:

1. Place a caret at a class name or any place within a class.

2. Select `Refactor | Extract/Introduce | Module` from the main menu.

3. In the Extract Module dialog, specify the module name, a directory where it should be placed, and select members to be added:

![Extract Module dialog](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_extract_module_dialog.png)

Click OK. RubyMine will create a module in a separate file.

## Example

Before:

```RUBY
# 'cat.rb' file
class Cat
    def breathe
        puts "inhale and exhale"
    end
    def speak
        puts "Meow"
    end
end
```

After:

```RUBY
# 'cat.rb' file
class Cat
    include Animal

    def speak
        puts "Meow"
    end
end

#
# 'animal.rb' file
module Animal
    def breathe
        puts "inhale and exhale"
    end
end
```

