Class: Atoyrobot::CLI

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.stdinObject

Returns the value of attribute stdin.



9
10
11
# File 'lib/atoyrobot/cli.rb', line 9

def stdin
  @stdin
end

Class Method Details

.start(_argv = [], args = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/atoyrobot/cli.rb', line 11

def start(_argv = [], args = {})
  self.stdin = args[:input] || STDIN
  robot = Robot.new
  loop do
    raw_input = stdin.gets&.chomp || ''
    break if raw_input.empty? || raw_input == 'exit'
    execute(raw_input, robot)
  end
end