summaryrefslogtreecommitdiff
path: root/examples/get_character.rb
blob: c0a666f5140788a1c9ca38dc0f93d4e9ea6e8127 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env ruby

require "rubygems"
require "highline/import"

puts "Using: #{HighLine.default_instance.terminal.class}"
puts

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}")