diff options
Diffstat (limited to 'examples/menus.rb')
-rw-r--r-- | examples/menus.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/examples/menus.rb b/examples/menus.rb index 258c1ca..64e20e6 100644 --- a/examples/menus.rb +++ b/examples/menus.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# encoding: utf-8 require "rubygems" require "highline/import" @@ -7,7 +8,7 @@ puts "Using: #{HighLine.default_instance.terminal.class}" puts # The old way, using ask() and say()... -choices = %w{ruby python perl} +choices = %w[ruby python perl] say("This is the old way using ask() and say()...") say("Please choose your favorite programming language:") say(choices.map { |c| " #{c}\n" }.join) @@ -24,11 +25,10 @@ say("\nThis is the new mode (default)...") choose do |menu| menu.prompt = "Please choose your favorite programming language? " - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end + menu.choice(:ruby) { say("Good choice!") } + menu.choices(:python, :perl) { say("Not from around here, are you?") } menu.default = :ruby - end say("\nThis is letter indexing...") @@ -38,8 +38,8 @@ choose do |menu| menu.prompt = "Please choose your favorite programming language? " - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end + menu.choice(:ruby) { say("Good choice!") } + menu.choices(:python, :perl) { say("Not from around here, are you?") } end say("\nThis is with a different layout...") @@ -49,8 +49,8 @@ choose do |menu| menu.header = "Languages" menu.prompt = "Favorite? " - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end + menu.choice(:ruby) { say("Good choice!") } + menu.choices(:python, :perl) { say("Not from around here, are you?") } end say("\nYou can even build shells...") @@ -60,10 +60,10 @@ loop do menu.shell = true - menu.choice(:load, "Load a file.") do |command, details| + menu.choice(:load, "Load a file.") do |_command, details| say("Loading file with options: #{details}...") end - menu.choice(:save, "Save a file.") do |command, details| + menu.choice(:save, "Save a file.") do |_command, details| say("Saving file with options: #{details}...") end menu.choice(:quit, "Exit program.") { exit } |