Module: Beet::Interaction

Included in:
Executor
Defined in:
lib/beet/interaction.rb

Instance Method Summary collapse

Instance Method Details

#ask(string) ⇒ Object

Get a user’s input

Example

answer = ask("Should I freeze the latest Rails?")
freeze! if ask("Should I freeze the latest Rails?") == "yes"


10
11
12
13
14
# File 'lib/beet/interaction.rb', line 10

def ask(string)
  log '', string 
  print '> '
  STDIN.gets.strip
end

#no?(question) ⇒ Boolean

Helper to test if the user does NOT say yes(y)?

Example

capify! if no?("Will you be using vlad to deploy your application?")

Returns:

  • (Boolean)


33
34
35
# File 'lib/beet/interaction.rb', line 33

def no?(question)
  !yes?(question)
end

#yes?(question) ⇒ Boolean

Helper to test if the user says yes(y)?

Example

freeze! if yes?("Should I freeze the latest Rails?")

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/beet/interaction.rb', line 22

def yes?(question)
  answer = ask(question).downcase
  answer == "y" || answer == "yes"
end