# 上移成员，下移成员

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

上移成员 重构允许您将类成员移动到指定的超类。  下移成员 将类成员移动到子类。

## 上移成员

要上移成员：

Procedure:

1. 将插入符号放置在类名或类中的任意位置：

![将插入符号放置](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_pull_up_caret.animated.gif)

2. 转到  `重构 | 上移成员...` 。

3. 在弹出的对话框中，选择所需的成员以及这些成员将被放置的超类：

![上移成员对话框](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_pull_up_dialog.png)

点击   确定  。

|  之前  |  之后  |
| --- | --- |
|    cat.rb   文件    ```RUBY class Cat < Mammal   def move     puts "move"   end   def speak     puts "Meow"   end end  ```    |    animal.rb   文件    ```RUBY class Animal def move puts "move" end end  ```     cat.rb   文件    ```RUBY class Cat < Mammal   def speak     puts "Meow"   end end  ```    |

## 下移成员

要下移成员：

Procedure:

1. 将插入符号放置在类名或类中的任意位置。

2. 在主菜单中，进入  `重构 | 向下推送成员...` .

3. 在弹出的对话框中，选择将被移动到子类的所需成员：

![下推成员对话框](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_push_down_dialog.png)

点击   确定  。

|  之前  |  之后  |
| --- | --- |
|    animal.rb   文件    ```RUBY class Animal def breathe puts "inhale and exhale" end def move puts "move" end end  ```     mammal.rb   文件    ```RUBY class Mammal < Animal end  ```    |    animal.rb   文件    ```RUBY class Animal def move puts "move" end end  ```     mammal.rb   文件    ```RUBY class Mammal < Animal   def breathe     puts "inhale and exhale"   end end  ```    |

## See also

### 操作步骤

[重构代码](refactoring-source-code.html)

