Sha256: aed65c5df9db25ccb3024881d7e4a5aacabb94ad60e0762b14ae41fd809a930a

Contents?: true

Size: 1.56 KB

Versions: 18

Compression:

Stored size: 1.56 KB

Contents

# 管理,保存各个加载的模块
class Aio::ModuleManager
	
#	def [](key)
#	end

	attr_accessor :modules, :modules_count

	# NOTE modules[reference_name] = {
	# 							:device_type
	#	  						:full_path
  #							  :klass
	def initialize
#		self.module_info_by_path = {}
#		self.module_load_error_by_path = {}
#		self.module_paths = []
		self.modules = {}
		self.modules_count = {}
	end

	# 加载一个目录下的所有模块
	# @param [String] path 目录的路径
	# @param [Hash] options
	def load_modules(path, options={})
	end

	# 将实例化后的模块类放到 modules 中
	def add_module(path, device_type, reference_name, module_klass)

		modules[reference_name] = {:device_type => device_type,
															 :full_path => path, 
															 :klass	=> module_klass
															}
	end

	# 通过设备类型获得模块类
	# 返回类型为: 数组
	def get_module_by_device_type(device_type)
		return_array = []

		device_type = device_type.to_s
		modules.each do |m|
			type = m[:device_type]
			if device_type == type
				return_array << m[:klass]
			end
			next
		end

		return return_array
	end
				
	# 获得所有加载模块的设备类型的字符串型
	# 返回类型为: 数组
	def get_modules_device_type_to_str
		return_array = []
		
		modules_counts.keys do |key|
			return_array << key.to_s
		end

		return return_array
	end
			
			
	# 判断此设备类型的模块是否加载
	def device_type_enable?(device_type)
		true
	end

	def notify(opts={})
		if opts[:count_by_device_type]
			@modules_count = opts[:count_by_device_type]
		end
	end
			

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
aio_elin-1.1.8 lib/aio/core/module_manager.rb.bak
aio_elin-1.1.7 lib/aio/core/module_manager.rb.bak
aio_elin-1.1.4 lib/aio/core/module_manager.rb.bak
aio_elin-1.1.3 lib/aio/core/module_manager.rb.bak
aio_elin-1.1.2 lib/aio/core/module_manager.rb.bak
aio_elin-1.1.1 lib/aio/core/module_manager.rb.bak
aio_elin-1.1.0 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.9 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.8 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.7 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.6 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.5 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.4 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.3 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.2 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.1 lib/aio/core/module_manager.rb.bak
aio_elin-1.0.0 lib/aio/core/module_manager.rb.bak
aio_elin-0.0.1 lib/aio/core/module_manager.rb.bak