RubyMine 2024.1 ヘルプ

モジュールの抽出

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

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

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

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

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

    Extract Module dialog

    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