class Aio::Module::InputStyle::Console::CmdContext
Attributes
all_info[RW]
all_info
= [[device_name, cmd, context] … ]
cmd[RW]
context[RW]
device_name[RW]
Public Class Methods
new()
click to toggle source
# File lib/modules/input/style/console.rb, line 54 def initialize @device_name = "" @cmd = "" @context = [] @all_info = [] end
Public Instance Methods
clear()
click to toggle source
# File lib/modules/input/style/console.rb, line 86 def clear @device_name = "" @cmd = "" @context = [] end
done()
click to toggle source
# File lib/modules/input/style/console.rb, line 61 def done # 当之前有cmd内容的时候,比较两个的长度 # 长的保留 info_idx = has_cmd? if info_idx if @all_info[info_idx][2].size < context.size @all_info[info_idx][2] = context end else # 如果都没有,那么就直接添加 @all_info << [device_name, cmd, context] end self.clear end
has_cmd?()
click to toggle source
# File lib/modules/input/style/console.rb, line 77 def has_cmd? @all_info.each_with_index do |info, idx| next unless info[0] == device_name return idx if info[1] == cmd end return nil end