module Aio::Parse require "aio/core/parse/parser_machine/parent_state" require "aio/core/parse/parser_machine/no_device_state" require "aio/core/parse/parser_machine/has_device_state" require "aio/core/parse/parser_machine/full_state" class ParserMachine # 保存状态机的状态 attr_reader :state # device_manager attr_reader :device_manager def initialize(device_manager) @device_manager = device_manager @no_device_state = Aio::Parse::NoDeviceState.new(self) @has_device_state = Aio::Parse::HasDeviceState.new(self) @full_state = Aio::Parse::FullState.new(self) @state = @no_device_state end def get_device(opts) @state.get_device(opts) end def get_full(opts) @state.get_full(opts) end # 状态的切换 def to_no_device_state @state = @no_device_state end def to_has_device_state @state = @has_device_state end def to_full_state @state = @full_state end end end