summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarcus Stollsteimer <sto.mar@web.de>2012-12-15 21:24:54 +0100
committerMarcus Stollsteimer <sto.mar@web.de>2012-12-15 21:24:54 +0100
commit698e2c748b1c22a5012ec8200d6582b0cd7b97b0 (patch)
tree8044433a763749f578be63f20a31aadcb02abeb8 /examples
parent016b8a35d62ba8b6562fc62bdc0e1d79531a9b44 (diff)
downloadhighline-698e2c748b1c22a5012ec8200d6582b0cd7b97b0.tar.gz
Adding an example for getting a character.
Diffstat (limited to 'examples')
-rw-r--r--examples/get_character.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/get_character.rb b/examples/get_character.rb
new file mode 100644
index 0000000..c22d412
--- /dev/null
+++ b/examples/get_character.rb
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+
+require "rubygems"
+require "highline/import"
+
+choices = "ynaq"
+answer = ask("Your choice [#{choices}]? ") do |q|
+ q.echo = false
+ q.character = true
+ q.validate = /\A[#{choices}]\Z/
+ end
+say("Your choice: #{answer}")