Sha256: 6c2ba5de349714b427d9a340ef7753d5ad263a874cffe7e84c068ad665743ed2
Contents?: true
Size: 1.73 KB
Versions: 17
Compression:
Stored size: 1.73 KB
Contents
#coding=utf-8 module Aio::Module class OutputStyle class OutputMethodError < StandardError def to_s "请重载此方法" end end # 输出的文件名 attr_accessor :output_file # 信息 attr_accessor :output_info # device_manager 加载 attr_accessor :device_manager # module_manager 加载 attr_accessor :module_manager def initialize(info={}) @output_info = info.dup set_defaults() end def set_defaults self.output_info = { :author => nil, :description => "No Output Description", :file_suffix => nil, :platform => ['unix', 'windows'], :license => ::Aio::AIO_LICENSE, }.update(@output_info) end def author; self.output_info[:author]; end def description; self.output_info[:description]; end def file_suffix; self.output_info[:file_suffix]; end def license; self.output_info[:license]; end def platform; self.output_info[:platform]; end def type Aio::Module::OutputStyle end # 输入的文件名,判断是否有后缀 # 如果没有则添加后缀 def output_file=(file_name) file_pathname = Pathname.new(file_name) if file_pathname.extname.empty? base, name = file_pathname.split suffix = output_info[:file_suffix] # 当不需要suffix, 将其设为空 unless /^\./ =~ suffix if suffix == "" or /(?i)null/ =~ suffix suffix = "" else suffix = "." + suffix end end name = name.to_s + suffix file_pathname = Pathname.new(base + name) end @output_file = file_pathname end def each_devices_with_useful self.device_manager.each_devices_with_useful do |k, v| yield k, v end end # 生成文件 def generate raise OutputMethodError.new end end end
Version data entries
17 entries across 17 versions & 1 rubygems