Class: Yoptparse::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/yoptparse/option.rb

Instance Method Summary collapse

Constructor Details

#initialize(argument_name:, argument_type:, command_class:) ⇒ Option


6
7
8
9
10
# File 'lib/yoptparse/option.rb', line 6

def initialize(argument_name:, argument_type:, command_class:)
  @argument_name = argument_name
  @argument_type = argument_type
  @command_class = command_class
end

Instance Method Details

#descriptionString


13
14
15
# File 'lib/yoptparse/option.rb', line 13

def description
  [description_main, description_suffix].compact.join(" ")
end

#long_optionString


18
19
20
# File 'lib/yoptparse/option.rb', line 18

def long_option
  "--#{chain_cased_argument_name}#{long_option_suffix}"
end

#type_classClass


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/yoptparse/option.rb', line 23

def type_class
  case tag.type
  when "Array"
    ::Array
  when "Float"
    ::Float
  when "Integer"
    ::Integer
  when "Numeric"
    ::Numeric
  when "OptionParser::DecimalInteger"
    ::OptionParser::DecimalInteger
  when "OptionParser::DecimalNumeric"
    ::OptionParser::DecimalNumeric
  when "OptionParser::OctalInteger"
    ::OptionParser::OctalInteger
  when "String"
    ::String
  else
    ::Object
  end
end