Class: Strobe::CLI::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/strobe/cli/input.rb

Defined Under Namespace

Classes: Menu

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdin = STDIN, stdout = STDOUT) ⇒ Input

Returns a new instance of Input.



47
48
49
# File 'lib/strobe/cli/input.rb', line 47

def initialize(stdin = STDIN, stdout = STDOUT)
  @stdin, @stdout = stdin, stdout
end

Instance Attribute Details

#stdinObject (readonly)

Returns the value of attribute stdin.



45
46
47
# File 'lib/strobe/cli/input.rb', line 45

def stdin
  @stdin
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



45
46
47
# File 'lib/strobe/cli/input.rb', line 45

def stdout
  @stdout
end

Instance Method Details

#agree(msg = nil) ⇒ Object



56
57
58
59
60
# File 'lib/strobe/cli/input.rb', line 56

def agree(msg = nil)
  print msg if msg
  c = gets.strip.downcase
  c == "y" || c.strip.blank?
end

#ask(msg = nil) ⇒ Object



51
52
53
54
# File 'lib/strobe/cli/input.rb', line 51

def ask(msg = nil)
  print msg if msg
  gets.strip
end

#ask_for_password(msg = nil) ⇒ Object



68
69
70
71
# File 'lib/strobe/cli/input.rb', line 68

def ask_for_password(msg = nil)
  print msg if msg
  running_on_windows? ? ask_for_password_on_windows : ask_for_password_on_others
end

#choose {|m| ... } ⇒ Object

Yields:

  • (m)


62
63
64
65
66
# File 'lib/strobe/cli/input.rb', line 62

def choose(&block)
  m = Menu.new(self)
  yield m
  m.ask
end

#gets(*args) ⇒ Object



81
82
83
# File 'lib/strobe/cli/input.rb', line 81

def gets(*args)
  stdin.gets(*args)
end


77
78
79
# File 'lib/strobe/cli/input.rb', line 77

def print(*args)
  stdout.print(*args)
end

#puts(*args) ⇒ Object



73
74
75
# File 'lib/strobe/cli/input.rb', line 73

def puts(*args)
  stdout.puts(*args)
end