Class: Aio::Module::InputStyle
- Inherits:
-
Object
- Object
- Aio::Module::InputStyle
- Defined in:
- lib/aio/core/module/input_style.rb
Direct Known Subclasses
Defined Under Namespace
Classes: CompareXML, Console, ErrorModuleInput, XinhuaNat
Instance Attribute Summary collapse
-
#ext_info ⇒ Object
外加信息,用于针对特殊情况.
-
#input_file ⇒ Object
重要! 输入文件.
-
#input_info ⇒ Object
信息.
Instance Method Summary collapse
- #author ⇒ Object
-
#check_file(file) ⇒ Object
保证输出的file为Pathname类.
- #description ⇒ Object
- #file_suffix ⇒ Object
-
#file_suffix?(file) ⇒ Boolean
检查是否符合文件后缀,符合返回真.
-
#initialize(info = {}) ⇒ InputStyle
constructor
A new instance of InputStyle.
- #license ⇒ Object
-
#parse ⇒ Object
请重载此方法.
- #pass_file ⇒ Object
-
#pass_file?(file) ⇒ Boolean
检查是否符合pass_file, 符合返回真.
- #platform ⇒ Object
- #set_defaults ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(info = {}) ⇒ InputStyle
Returns a new instance of InputStyle.
22 23 24 25 |
# File 'lib/aio/core/module/input_style.rb', line 22 def initialize(info={}) @input_info = info.dup set_defaults() end |
Instance Attribute Details
#ext_info ⇒ Object
外加信息,用于针对特殊情况
20 21 22 |
# File 'lib/aio/core/module/input_style.rb', line 20 def ext_info @ext_info end |
#input_file ⇒ Object
重要!输入文件
14 15 16 |
# File 'lib/aio/core/module/input_style.rb', line 14 def input_file @input_file end |
#input_info ⇒ Object
信息
17 18 19 |
# File 'lib/aio/core/module/input_style.rb', line 17 def input_info @input_info end |
Instance Method Details
#author ⇒ Object
89 |
# File 'lib/aio/core/module/input_style.rb', line 89 def ; self.input_info[:author]; end |
#check_file(file) ⇒ Object
保证输出的file为Pathname类
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/aio/core/module/input_style.rb', line 45 def check_file(file) if file.class != Pathname case file.class when String file = Pathname.new(file) when File file = Pathname.new(file.path) end end file end |
#description ⇒ Object
90 |
# File 'lib/aio/core/module/input_style.rb', line 90 def description; self.input_info[:description]; end |
#file_suffix ⇒ Object
92 |
# File 'lib/aio/core/module/input_style.rb', line 92 def file_suffix; self.input_info[:file_suffix]; end |
#file_suffix?(file) ⇒ Boolean
检查是否符合文件后缀,符合返回真
63 64 65 66 67 68 |
# File 'lib/aio/core/module/input_style.rb', line 63 def file_suffix?(file) if self.file_suffix.match(file) return true end return false end |
#license ⇒ Object
93 |
# File 'lib/aio/core/module/input_style.rb', line 93 def license; self.input_info[:license]; end |
#parse ⇒ Object
请重载此方法
58 59 60 |
# File 'lib/aio/core/module/input_style.rb', line 58 def parse raise ErrorModuleInput.new end |
#pass_file ⇒ Object
94 |
# File 'lib/aio/core/module/input_style.rb', line 94 def pass_file; self.input_info[:pass_file]; end |
#pass_file?(file) ⇒ Boolean
检查是否符合pass_file, 符合返回真
71 72 73 74 75 76 77 78 |
# File 'lib/aio/core/module/input_style.rb', line 71 def pass_file?(file) self.pass_file.each do |pass| if pass.match(Aio::Base::Toolkit::String.safe(file)) return true end end return false end |
#platform ⇒ Object
91 |
# File 'lib/aio/core/module/input_style.rb', line 91 def platform; self.input_info[:platform]; end |
#set_defaults ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aio/core/module/input_style.rb', line 27 def set_defaults self.input_info = { :author => nil, :description => "No Input Description", # 产生文件的平台 :platform => nil, :file_suffix => nil, :pass_file => nil, :license => ::Aio::AIO_LICENSE, }.update(@input_info) end |
#type ⇒ Object
40 41 42 |
# File 'lib/aio/core/module/input_style.rb', line 40 def type Aio::Module::InputStyle end |