Class: Yoptparse::Option
- Inherits:
-
Object
- Object
- Yoptparse::Option
- Defined in:
- lib/yoptparse/option.rb
Instance Method Summary collapse
- #description ⇒ String
-
#initialize(argument_name:, argument_type:, command_class:) ⇒ Option
constructor
A new instance of Option.
- #long_option ⇒ String
- #type_class ⇒ Class
Constructor Details
#initialize(argument_name:, argument_type:, command_class:) ⇒ Option
Returns a new instance of 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
#description ⇒ String
13 14 15 |
# File 'lib/yoptparse/option.rb', line 13 def description [description_main, description_suffix].compact.join(" ") end |
#long_option ⇒ String
18 19 20 |
# File 'lib/yoptparse/option.rb', line 18 def long_option "--#{chain_cased_argument_name}#{long_option_suffix}" end |
#type_class ⇒ Class
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/yoptparse/option.rb', line 23 def type_class if tag 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 else ::Object end end |