Class: Aio::Module::InputStyle::Console::ContextState
- Defined in:
- lib/modules/input/style/console.rb
Instance Method Summary collapse
Methods inherited from State
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
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/modules/input/style/console.rb', line 138 def parse_line(line) # 如果这行是命令行格式,那么就代表上一个cmd内容结束 # 如果这里出问题,关注 CmdState tmp_reg = ::Regexp.new "^[\\[|<]?#{cmd_context.device_name}[#|>|\\]]{1}" # 可能会出现UTF-8识别不出摄氏度符号的问题 # 已经通过安全字符解决 begin if tmp_reg.match(line) cmd_context.done # 完成后将状态设置为空,并且重新分析这一行 # 毕竟如果这行也cmd行呢 @machine.to_empty_state return @machine.parse_line(line) end rescue => e print_error cmd_context.device_name + " 设备巡检信息编码出现问题" print_error line + " : " + e. end cmd_context.context << line end |