Sha256: 471016a948d25ddff259255c49ff76b0294d8a05cfc8b5e5a30dc06a4cc6228c

Contents?: true

Size: 502 Bytes

Versions: 6

Compression:

Stored size: 502 Bytes

Contents

module Kernel

  module_function

  # Very simple convenience method to get a console reply.
  #
  #   ask "Are you happy?", "Yn"
  #
  # On the command line one would see.
  #
  #   $ Are you happy? [Yn]
  #
  # Responding:
  #
  #   $ Are you happy? [Yn] Y <ENTER>
  #
  # The ask method would return "Y".

  def ask(question, answers=nil)
    $stdout << "#{question}"
    $stdout << " [#{answers}] " if answers
    $stdout.flush
    until inp = $stdin.gets ; sleep 1 ; end
    inp.strip
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/kernel/ask.rb
facets-2.8.3 lib/core/facets/kernel/ask.rb
facets-2.8.2 lib/core/facets/kernel/ask.rb
facets-2.8.1 lib/core/facets/kernel/ask.rb
facets-2.8.0 lib/core/facets/kernel/ask.rb
facets-2.7.0 lib/core/facets/kernel/ask.rb