class BBS::Terminal::Question
The question itself, in plain ASCII capitals: the faces, a digit each, and the guess as the default. A key only picks, RETURN takes it; a changed pick prints the prompt again on a new line.
Constants
- TAKE_KEYS
-
The keys that take the pick.
- UNPICK_KEYS
-
The keys that take the pick back.
Public Class Methods
Source
# File lib/bbs/terminal.rb, line 83 def initialize(session, title) @session = session @title = title @default = Terminal.guess(session) @picked = nil end
The question of title for session.
Public Instance Methods
Source
# File lib/bbs/terminal.rb, line 92 def ask @session.write question loop do key = @session.readkey(timeout: WAIT) return nil if key.nil? break if TAKE_KEYS.include?(key) pick(choice(key)) end @session.write @picked ? Ansi::CRLF : "#{FACES[@default][:digit]}#{Ansi::CRLF}" @picked || @default end
Asks, and returns :modern or :petscii; nil when the line drops.