RubyMine 6.3.0 Web Help

RubyMine provides the following inline refactorings:

  • The Inline Variable refactoring replaces redundant variable usage with its initializer. This refactoring is opposite to Extract Variable.

    Tip

    The variable must be initialized at declaration. If the initial value is modified somewhere in the code, only the occurrences before modification will be inlined.

  • The Inline Method refactoring results in placing the method's body into the body of its caller(s); the method is deleted. This refactoring is opposite Extract Method.

Examples

Before After
Inline variable
                  def 
                  human_start_turn
                  human_player = @game.human_player
    human_player.roller = roller
    human_player.start_turn
    human_player.roll_dice
    human_player.save!
    redirect_to_human_turn_game_path(@game)
end
               
                  def 
                  
                      human_start_turn
                  
                  @game.human_player.roller = roller
    @game.human_player.start_turn
    @game.human_player.roll_dice
    @game.human_player.save!
    redirect_to_human_turn_game_path(@game)
end
               
Inline method
                  def color(text,color_code)
"#{color_code}#{text}\e[0m]"
end
                  def green(text);color(text,"
                  \e
                  [32m");end
                  if color_code::equal?("
                  \e
                  [32m")then
  puts green("ANSI:green")
end
               
                  def color(text,color_code)
"#{color_code}#{text}\e[0m]"
end
                  if color_code::equal?("
                  \e
                  [32m")then
  puts color("ANSI:green", "
                  \e
                  [32m")
end
               
To perform the inline refactoring
  1. Place the caret in the editor at the desired symbol to be inlined.
  2. Do one of the following:
    • On the main menu or on the context menu of the selection, choose Refactor | Inline.
    • Press Ctrl+Alt+NCtrl+Alt+NCtrl+Alt+NCtrl+Alt+NCtrl+Alt+NCtrl+Alt+NCtrl+Alt+NShift+Alt+IAlt+Meta+NAlt Command NAlt Command NAlt Command IAlt Command N.
  3. In the Inline dialog, that corresponds to the selected symbol, specify the inlining options.
  4. Preview and apply changes.

See Also

Procedures:

Reference:

Web Resources: