class Aio::Parse::HasDeviceState

Public Instance Methods

check_full(opts={}) click to toggle source

验证是否有cmd和context了

# File lib/aio/core/parse/parser_machine/has_device_state.rb, line 22
def check_full(opts={})
  device_name = opts[:device_name]
  device_klass = self.device_manager.devices[device_name]

  org_cmd = opts[:cmd]
  org_context = opts[:context]
  org_cmd_reg = Aio::Base::Toolkit::Regexp.to_reg(org_cmd)
  device_klass.cmds_context.each_pair do |cmd, context|

    # 只有当有cmd, 并且context不为空的时候才算有
    # FIXME 可以在这里的context类加入.check_avlid? 查看是否有效
    if org_cmd_reg.match(cmd)
      if ! context.empty?
        return true
      end
    end

  end
  return false
end
get_device(opts) click to toggle source
# File lib/aio/core/parse/parser_machine/has_device_state.rb, line 4
def get_device(opts)
  self.device_manager.add_device(opts)
end
get_full(opts) click to toggle source
# File lib/aio/core/parse/parser_machine/has_device_state.rb, line 8
def get_full(opts)

  if ! check_full(opts)
    no_full
  elsif
    @machine.to_full_state
  end

end
no_full() click to toggle source
# File lib/aio/core/parse/parser_machine/has_device_state.rb, line 18
def no_full
end