Class: Aio::Parse::HasDeviceState

Inherits:
ParentState show all
Defined in:
lib/aio/core/parse/parser_machine/has_device_state.rb

Instance Method Summary collapse

Methods inherited from ParentState

#device_manager, #initialize

Constructor Details

This class inherits a constructor from Aio::Parse::ParentState

Instance Method Details

#check_full(opts = {}) ⇒ Object

验证是否有cmd和context了



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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) ⇒ Object



4
5
6
# 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) ⇒ Object



8
9
10
11
12
13
14
15
16
# 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_fullObject



18
19
# File 'lib/aio/core/parse/parser_machine/has_device_state.rb', line 18

def no_full
end