File: get_character.rb

package info (click to toggle)
ruby-highline 3.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 800 kB
  • sloc: ruby: 5,789; sh: 7; makefile: 4
file content (16 lines) | stat: -rw-r--r-- 323 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env ruby
# encoding: utf-8

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