added example_basic.rb, to demonstrate basic functionality

This commit is contained in:
John Mair 2011-02-05 16:14:28 +13:00
parent f06599bd8b
commit 971bba3c38
2 changed files with 18 additions and 0 deletions

View File

@ -286,6 +286,7 @@ Example Programs
Pry comes bundled with a few example programs to illustrate some
features, see the `examples/` directory.
* `example_basic.rb` - Demonstrate basic Pry functionality
* `example_input.rb` - Demonstrates how to set the `input` object.
* `example_output.rb` - Demonstrates how to set the `output` object.
* `example_hooks.rb` - Demonstrates how to set the `hooks` hash.

17
examples/example_basic.rb Normal file
View File

@ -0,0 +1,17 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
# define a local.
a = "a local variable"
# defing a top-level method.
def hello
puts "hello world!"
end
# Start pry session at top-level.
# The local variable `a` and the `hello` method will
# be accessible.
pry