# スーパークラスの抽出作成

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

> **TL;DR**
> `リファクタリング | 抽出 / 導入 | スーパークラス`

スーパークラスの抽出 リファクタリングを使用すると、選択したクラスから特定のメンバーを新しい基本クラスに抽出できます。 元のクラスは作成された基本クラスから継承されます。

スーパークラスを抽出するには

Procedure:

1. クラス名またはクラス内の任意の場所にキャレットを置きます。

2. メインメニューから  `リファクタリング | 抽出 / 導入 | スーパークラス`  を選択します。

3. スーパークラスの抽出   ダイアログで、スーパークラスの名前、配置先のディレクトリを指定し、追加するメンバーを選択します。

![スーパークラスの抽出ダイアログ](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_extract_superclass_dialog.png)

OK   をクリックしてください。 RubyMine は別のファイルにスーパークラスを作成します。

## サンプル

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
require_relative 'mammal.rb'
class Cat < Mammal
    def speak
        puts "Meow"
    end
end
#
# 'mammal.rb' file
class Mammal < Object
    def breathe
        puts "inhale and exhale"
    end
end

```

## See also

### 外部リンク

