Class: Aio::Ui::Banner
- Inherits:
-
Object
- Object
- Aio::Ui::Banner
- Defined in:
- lib/aio/ui/banner.rb
Instance Attribute Summary collapse
-
#compare ⇒ Object
Returns the value of attribute compare.
-
#input ⇒ Object
Returns the value of attribute input.
-
#input_style ⇒ Object
Returns the value of attribute input_style.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#output ⇒ Object
Returns the value of attribute output.
-
#output_style ⇒ Object
Returns the value of attribute output_style.
-
#ranking ⇒ Object
Returns the value of attribute ranking.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #banner ⇒ Object
-
#check(opt) ⇒ Object
检查参数是否合法.
-
#has_input? ⇒ Boolean
判断是否有 input 信息.
-
#initialize ⇒ Banner
constructor
A new instance of Banner.
- #parse(args = []) ⇒ Object
Constructor Details
#initialize ⇒ Banner
Returns a new instance of Banner.
32 33 34 |
# File 'lib/aio/ui/banner.rb', line 32 def initialize @type = "" end |
Instance Attribute Details
#compare ⇒ Object
Returns the value of attribute compare.
12 13 14 |
# File 'lib/aio/ui/banner.rb', line 12 def compare @compare end |
#input ⇒ Object
Returns the value of attribute input.
9 10 11 |
# File 'lib/aio/ui/banner.rb', line 9 def input @input end |
#input_style ⇒ Object
Returns the value of attribute input_style.
9 10 11 |
# File 'lib/aio/ui/banner.rb', line 9 def input_style @input_style end |
#mode ⇒ Object
Returns the value of attribute mode.
7 8 9 |
# File 'lib/aio/ui/banner.rb', line 7 def mode @mode end |
#output ⇒ Object
Returns the value of attribute output.
11 12 13 |
# File 'lib/aio/ui/banner.rb', line 11 def output @output end |
#output_style ⇒ Object
Returns the value of attribute output_style.
11 12 13 |
# File 'lib/aio/ui/banner.rb', line 11 def output_style @output_style end |
#ranking ⇒ Object
Returns the value of attribute ranking.
10 11 12 |
# File 'lib/aio/ui/banner.rb', line 10 def ranking @ranking end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/aio/ui/banner.rb', line 8 def type @type end |
Instance Method Details
#banner ⇒ Object
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 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 =~ /-/ end return opt end |
#has_input? ⇒ Boolean
判断是否有 input 信息
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=[]) 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" end end self end |