# 用于调用描述信息 module Aio::Warning class Description # Description模块 attr_accessor :modules def initialize(module_manager) @modules = {} @parent_klass = Aio::Module::Description.new modules_info = module_manager.get_modules_by_type("description") tidy_modules(modules_info) end # 整理后的格式为 # modules = { :crc => klass } def tidy_modules(module_info) module_info.each_value do |info| md = info[:klass] self.modules[md.case] = md end end # 通过case获取模块的实例 def get_desc(sym) modules.each_pair do |cs, klass| case cs when ::Array if cs.include?(sym) return klass end when ::Symbol if cs == sym.to_sym return klass end when ::String if cs == sym.to_s return klass end end end return @parent_klass.temp(sym) end end end