Sha256: 8642330e7288cc35e5a316cac54317ddd2e657252685d3de32c5bf7de9402dad

Contents?: true

Size: 480 Bytes

Versions: 3

Compression:

Stored size: 480 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)
    print "#{question}"
    print " [#{answers}] " if answers
    until inp = $stdin.gets ; sleep 1 ; end ; puts
    inp.strip
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.2.0 lib/core/facets/kernel/ask.rb
facets-2.3.0 lib/core/facets/kernel/ask.rb
facets-2.2.1 lib/core/facets/kernel/ask.rb