RubyMine 2026.2 Help

モジュールの抽出

モジュールの抽出リファクタリングにより、選択したクラスから特定のメンバーを別々のモジュールに抽出することができます。

モジュールを抽出するには

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

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

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

    モジュールの抽出ダイアログ

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

サンプル

# 'cat.rb' file class Cat def breathe puts "inhale and exhale" end def speak puts "Meow" end end
# '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
2026 年 7 月 14 日