Class: Object

Inherits:
BasicObject
Defined in:
lib/highline/import.rb

Overview

When requiring ‘highline/import’ HighLine adds #or_ask to Object so

it is globally available.

Instance Method Summary collapse

Instance Method Details

#or_ask(*args, &details) ⇒ String

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.

Parameters:

  • args (Array<#to_s>)
  • details (lambda)

    block to be called with the question instance as argument.

Returns:



41
42
43
44
45
46
47
# File 'lib/highline/import.rb', line 41

def or_ask(*args, &details)
  ask(*args) do |question|
    question.first_answer = String(self)

    yield(question) if details
  end
end