diff --git a/lib/pry/commands.rb b/lib/pry/commands.rb index d3677744..fd319194 100644 --- a/lib/pry/commands.rb +++ b/lib/pry/commands.rb @@ -439,5 +439,47 @@ e.g: show-method hello_method alias_command "quit", "exit", "" alias_command "back", "exit", "" - end + + command "game", "" do |highest| + highest = highest ? highest.to_i : 100 + num = rand(highest) + output.puts "Guess the number between 0-#{highest}: ('.' to quit)" + count = 0 + while(true) + count += 1 + str = Readline.readline("game > ", true).chomp + break if str == "." + val = str.to_i + output.puts "Too large!" if val > num + output.puts "Too small!" if val < num + if val == num + output.puts "Well done! You guessed right! It took you #{count} guesses." + break + end + end + end + + command "cohen-poem", "" do + text = %{ +-- +When this American woman, +whose thighs are bound in casual red cloth, +comes thundering past my sitting place +like a forest-burning Mongol tribe, +the city is ravished +and brittle buildings of a hundred years +splash into the street; +and my eyes are burnt +for the embroidered Chinese girls, +already old, +and so small between the thin pines +on these enormous landscapes, +that if you turn your head +they are lost for hours. +-- Leonard Cohen + } + output.puts text + text +end +end end diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 47d23b7f..68171a96 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -102,6 +102,7 @@ class Pry # @param [String] arg_string The Pry command (including arguments, # if any). # @param [Hash] options Optional named parameters. + # @return [Object] The return value of the Pry command. # @option options [Object, Binding] :context The object context to run the # command under. Defaults to `TOPLEVEL_BINDING` (main). # @option options [Boolean] :show_output Whether to show command diff --git a/lib/pry/version.rb b/lib/pry/version.rb index 5609a8a3..1b39610c 100644 --- a/lib/pry/version.rb +++ b/lib/pry/version.rb @@ -1,3 +1,3 @@ class Pry - VERSION = "0.5.4" + VERSION = "0.5.5" end