Module: Mybot::Helpers

Includes:
Fmt
Included in:
Base
Defined in:
lib/mybot/helpers.rb

Constant Summary

Constants included from Fmt

Fmt::WIDTH

Instance Method Summary collapse

Methods included from Fmt

#asterisks, #colored, #print_cmd, #print_cmd!, #print_progress, #print_stderr, #print_stdout, #spaces

Instance Method Details

#ask(q = "") ⇒ Object



10
11
12
13
# File 'lib/mybot/helpers.rb', line 10

def ask(q = "")
  print_cmd "ask", q, :blue, :bold
  $stdin.gets.chomp
end

#wait(msg = "Press any key to continue...") ⇒ Object



5
6
7
8
# File 'lib/mybot/helpers.rb', line 5

def wait(msg = "Press any key to continue...")
  print_cmd "wait", msg, :blue, :bold
  $stdin.gets
end

#yes?(q = "") ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
# File 'lib/mybot/helpers.rb', line 15

def yes?(q = "")
  result = ""
  loop do
    print_cmd "ask", q, :blue, :bold
    result = $stdin.gets.chomp
    break if result =~ /y|yes|Y|YES|Yes|n|no|N|NO|No/
  end

  result =~ /y|yes|Y|YES|Yes/
end