RubyEditorDemo

Ruby Editor Demo (5 Minutes)

Description

This demos shows some of the features of the NetBeans Ruby Editor. For a more complete list, see the Editing Ruby Code article.

Product Versions Supported

NetBeans 6.0

Points to Hit

  • Code completion and integrated RDoc
  • Pair matching


Demo Prep

Create a Ruby project and put the following code into main.rb:

# A representation of the little pigs
class ThreePigs
  
  # This little piggy went to the market
  def pig_one(arg1)
    puts "Pig One: #{arg1}"
  end
  
  # This little piggy stayed home
  def pig_two(arg1, arg2)
    puts "Pig Two: #{arg2}"
  end
  
  # This little piggy had roast beast
  def pig_n(*args)
    puts "Pig N: #{args.inspect}"    
  end
  
end

Gotchas

  • None known

Ruby Editor Demo

Code Completion and Integrated RDoc

  • Move to the bottom of main.rb and type the following:

tp = Three<Ctrl+K>

to insert the previous matching word "LittlePigs". You now have lp = LittlePigs. Complete the line by adding .new, lp = LittlePigs.new (there's also code-completion for .new if you want to show it).
  • Show how the class's 3 local methods appear above the line, presuming to be your most logical choice. Also see the integraded RDoc.
    tp.<Ctrl+Space>

    Select the method with 2 arguments.
  • Enter arguments for the completed method using argument completion (entering a value and then pressing enter)

Mark Occurances, Go To Declaration, Instant Rename and Semantic Highlighting

  • Place your cursor on the call to method_two. Notice how method_two above is marked.
  • Ctrl+Click to go to that method's declaration
  • Highlight the arg1 and notice the only other occurrence of arg1 are NOT highlighted.
  • Select arg2 and Ctrl+R to instantly rename arg2 to something else.
  • Point out that the gray wavy underline below the arg1 indicates the variable is unused.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo