Class: Aio::Ui::Banner

Inherits:
Object
  • Object
show all
Defined in:
lib/aio/ui/banner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBanner

Returns a new instance of Banner.



32
33
34
# File 'lib/aio/ui/banner.rb', line 32

def initialize
	@type = ""
end

Instance Attribute Details

#compareObject

Returns the value of attribute compare.



12
13
14
# File 'lib/aio/ui/banner.rb', line 12

def compare
  @compare
end

#inputObject

Returns the value of attribute input.



9
10
11
# File 'lib/aio/ui/banner.rb', line 9

def input
  @input
end

#input_styleObject

Returns the value of attribute input_style.



9
10
11
# File 'lib/aio/ui/banner.rb', line 9

def input_style
  @input_style
end

#modeObject

Returns the value of attribute mode.



7
8
9
# File 'lib/aio/ui/banner.rb', line 7

def mode
  @mode
end

#outputObject

Returns the value of attribute output.



11
12
13
# File 'lib/aio/ui/banner.rb', line 11

def output
  @output
end

#output_styleObject

Returns the value of attribute output_style.



11
12
13
# File 'lib/aio/ui/banner.rb', line 11

def output_style
  @output_style
end

#rankingObject

Returns the value of attribute ranking.



10
11
12
# File 'lib/aio/ui/banner.rb', line 10

def ranking
  @ranking
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/aio/ui/banner.rb', line 8

def type
  @type
end

Instance Method Details



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/aio/ui/banner.rb', line 14

def banner
	res = %Q^
Usage: ./aio [option] <var>

Options:
	-l,   --list              [type]            显示所有或者所选type类型的模块信息
	-c,   --compare           <path1>           被比较的文件路径
	-is,  --input-style       <mod>             输入的模块名称
	-i,   --input             <path>            输入信息的绝对路径
	-r,   --ranking           <level>           选择命令的级别
	-os,  --output-style      <mod>             输出的模块名称
	-o,   --output            <path>            输出信息的路径
	-h,   --help                                帮助
^
	print res
	exit 0
end

#check(opt) ⇒ Object

检查参数是否合法



68
69
70
71
72
73
74
75
# File 'lib/aio/ui/banner.rb', line 68

def check(opt)
	opt = opt.to_s
	if opt.empty? and opt =~ /-/
		banner
	end

	return opt
end

#has_input?Boolean

判断是否有 input 信息

Returns:

  • (Boolean)


78
79
80
81
# File 'lib/aio/ui/banner.rb', line 78

def has_input?
	return false if @input_style.nil? and @input.nil?
	return true
end

#parse(args = []) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/aio/ui/banner.rb', line 36

def parse(args=[])
	banner if args.empty?

	while(!args.empty?) do 
		arg = args.shift
		case arg
		when "-l", "--list"
			@type = args.shift unless args[0] =~ /-/
			self.mode = 0
		when "-is", "--inupt-style"
			@input_style = check(args.shift)
			self.mode = 1
		when "-i", "--input"
			@input = check(args.shift)
		when "-r", "--ranking"
			@ranking = check(args.shift)
		when "-c", "--compare"
			@compare = check(args.shift)
		when "-os", "--output-style"
			@output_style = check(args.shift)
			self.mode = 1
		when "-o", "--output"
			@output = check(args.shift)
		when "-h", "--help"
			banner
		end
	end

	self
end