Class: Aio::Module::InputStyle::Console::CmdState

Inherits:
State
  • Object
show all
Defined in:
lib/modules/input/style/console.rb

Instance Method Summary collapse

Methods inherited from State

#cmd_context, #initialize

Methods included from Ui::Verbose

#clear_line, #print_error, #print_good, #progress_bar

Constructor Details

This class inherits a constructor from Aio::Module::InputStyle::Console::State

Instance Method Details

#parse_line(line) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/modules/input/style/console.rb', line 121

def parse_line(line)
  # 判断是不是cmd命令行
  res = /^[\[|<]?(?<name>[^\s]*)(#|>|\])(?<cmd>.*)/.match(line)
  if res.nil?
    @machine.to_empty_state
    return
  end

  # 当已经发现了是cmd行,那么紧接下来就是收集文本内容
  cmd_context.device_name = res[:name]
  cmd_context.cmd = res[:cmd].strip
  @machine.to_context_state
end