Class: S7n::S7nCli::Option

Inherits:
Object
  • Object
show all
Includes:
GetText
Defined in:
lib/s7n/s7ncli/option.rb

Overview

Option クラスとそれを継承したクラスは Ximapd プロジェクトからコピー しています。

Direct Known Subclasses

ArrayOption, BoolOption, IntOption, StringOption

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Option

Returns a new instance of Option.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/s7n/s7ncli/option.rb', line 14

def initialize(*args)
  case args.length
  when 2
    @name, @description = *args
    @arg_name = nil
  when 3
    @short_name, @name, @description = *args
  when 4
    @short_name, @name, @arg_name, @description = *args
  else
    msg = _("wrong # of arguments (%d for 2)") % args.length
    raise ArgumentError, msg
  end
end

Instance Method Details

#arg_nameObject



33
34
35
36
37
38
# File 'lib/s7n/s7ncli/option.rb', line 33

def arg_name
  if @arg_name.nil?
    @arg_name = @name.slice(/[a-z]*\z/ni).upcase
  end
  return @arg_name
end

#opt_nameObject



29
30
31
# File 'lib/s7n/s7ncli/option.rb', line 29

def opt_name
  return @name.tr("_", "-")
end