Class: Aio::Module::InputStyle

Inherits:
Object
  • Object
show all
Defined in:
lib/aio/core/module/input_style.rb

Direct Known Subclasses

CompareXML, Console, XinhuaNat

Defined Under Namespace

Classes: CompareXML, Console, ErrorModuleInput, XinhuaNat

Instance Attribute Summary collapse

Instance Method Summary collapse

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_infoObject

外加信息,用于针对特殊情况



20
21
22
# File 'lib/aio/core/module/input_style.rb', line 20

def ext_info
  @ext_info
end

#input_fileObject

重要!输入文件



14
15
16
# File 'lib/aio/core/module/input_style.rb', line 14

def input_file
  @input_file
end

#input_infoObject

信息



17
18
19
# File 'lib/aio/core/module/input_style.rb', line 17

def input_info
  @input_info
end

Instance Method Details

#authorObject



89
# File 'lib/aio/core/module/input_style.rb', line 89

def author;    		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

#descriptionObject



90
# File 'lib/aio/core/module/input_style.rb', line 90

def description;  self.input_info[:description];  end

#file_suffixObject



92
# File 'lib/aio/core/module/input_style.rb', line 92

def file_suffix;	self.input_info[:file_suffix];	end

#file_suffix?(file) ⇒ Boolean

检查是否符合文件后缀,符合返回真

Returns:

  • (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

#licenseObject



93
# File 'lib/aio/core/module/input_style.rb', line 93

def license;   		self.input_info[:license];   		end

#parseObject

请重载此方法

Raises:



58
59
60
# File 'lib/aio/core/module/input_style.rb', line 58

def parse
	raise ErrorModuleInput.new			
end

#pass_fileObject



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, 符合返回真

Returns:

  • (Boolean)


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

#platformObject



91
# File 'lib/aio/core/module/input_style.rb', line 91

def platform;  		self.input_info[:platform];  		end

#set_defaultsObject



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

#typeObject



40
41
42
# File 'lib/aio/core/module/input_style.rb', line 40

def type
	Aio::Module::InputStyle
end