Sha256: c9ae356ad6d8c7d6e649e1e7f2976f035ad58d6f3fee06e7436e856b85dae3bb

Contents?: true

Size: 1.23 KB

Versions: 144

Compression:

Stored size: 1.23 KB

Contents

#!/usr/local/bin/ruby -w

# import.rb
#
#  Created by James Edward Gray II on 2005-04-26.
#  Copyright 2005 Gray Productions. All rights reserved.
#
#  This is Free Software.  See LICENSE and COPYING for details.

require "highline"
require "forwardable"

$terminal = HighLine.new

#
# <tt>require "highline/import"</tt> adds shortcut methods to Kernel, making
# agree(), ask(), choose() and say() globally available.  This is handy for
# quick and dirty input and output.  These methods use the HighLine object in
# the global variable <tt>$terminal</tt>, which is initialized to used
# <tt>$stdin</tt> and <tt>$stdout</tt> (you are free to change this).
# Otherwise, these methods are identical to their HighLine counterparts, see that
# class for detailed explanations.
#
module Kernel
  extend Forwardable
  def_delegators :$terminal, :agree, :ask, :choose, :say
end

class Object
  # 
  # Tries this object as a _first_answer_ for a HighLine::Question.  See that
  # attribute for details.
  # 
  # *Warning*:  This Object will be passed to String() before set.
  # 
  def or_ask( *args, &details )
    ask(*args) do |question|
      question.first_answer = String(self) unless nil?
      
      details.call(question) unless details.nil?
    end
  end
end

Version data entries

144 entries across 140 versions & 17 rubygems

Version Path
delano-rye-0.6.2 vendor/highline-1.5.1/lib/highline/import.rb
delano-rye-0.6.3 vendor/highline-1.5.1/lib/highline/import.rb
delano-rye-0.6.4 vendor/highline-1.5.1/lib/highline/import.rb
malysz87-highline-1.5.10 lib/highline/import.rb
malysz87-highline-1.5.11 lib/highline/import.rb
malysz87-highline-1.5.4 lib/highline/import.rb
malysz87-highline-1.5.5 lib/highline/import.rb
motomike-bnr_tools-0.0.2 lib/highline/import.rb
motomike-bnr_tools-0.0.3 lib/highline/import.rb
motomike-bnr_tools-0.0.4 lib/highline/import.rb
motomike-bnr_tools-0.0.5 lib/highline/import.rb
motomike-bnr_tools-0.0.6 lib/highline/import.rb
motomike-bnr_tools-0.0.7 lib/highline/import.rb
solutious-rudy-0.6.0 vendor/highline-1.5.1/lib/highline/import.rb
solutious-rudy-0.6.1 vendor/highline-1.5.1/lib/highline/import.rb
solutious-rudy-0.6.2 vendor/highline-1.5.1/lib/highline/import.rb
solutious-rudy-0.6.3 vendor/highline-1.5.1/lib/highline/import.rb
solutious-rudy-0.6.4 vendor/highline-1.5.1/lib/highline/import.rb
solutious-rudy-0.6.5 vendor/highline-1.5.1/lib/highline/import.rb
solutious-rudy-0.6.6 vendor/highline-1.5.1/lib/highline/import.rb