Class: Protobox::Util::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/protobox/util.rb

Class Method Summary collapse

Class Method Details

.enter_or_abortObject



63
64
65
66
67
68
69
# File 'lib/protobox/util.rb', line 63

def enter_or_abort
  puts
  puts "Press ENTER to continue or any other key to abort"
  c = get_char
  #p c
  abort unless c == "\r"
end

.get_charObject



53
54
55
56
57
58
59
60
61
# File 'lib/protobox/util.rb', line 53

def get_char
  begin
    system("stty raw -echo")
    str = STDIN.getc
  ensure
    system("stty -raw echo")
  end
  str.chr
end

.get_inputObject



49
50
51
# File 'lib/protobox/util.rb', line 49

def get_input 
  STDIN.gets.chomp
end