Class: CLI::Kit::Args::Definition::Flag
- Inherits:
-
Object
- Object
- CLI::Kit::Args::Definition::Flag
- Extended by:
- T::Sig
- Includes:
- OptBase
- Defined in:
- lib/cli/kit/args/definition.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#long ⇒ Object
readonly
Returns the value of attribute long.
-
#short ⇒ Object
readonly
Returns the value of attribute short.
Attributes included from OptBase
Instance Method Summary collapse
- #as_written_by_user ⇒ Object
-
#initialize(name:, short: nil, long: nil, desc: nil) ⇒ Flag
constructor
A new instance of Flag.
Methods included from T::Sig
Constructor Details
#initialize(name:, short: nil, long: nil, desc: nil) ⇒ Flag
Returns a new instance of Flag.
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/cli/kit/args/definition.rb', line 149 def initialize(name:, short: nil, long: nil, desc: nil) if long&.start_with?('-') || short&.start_with?('-') raise(ArgumentError, 'invalid - prefix') end @name = name @short = short @long = long @desc = desc end |
Instance Attribute Details
#long ⇒ Object (readonly)
Returns the value of attribute long.
141 142 143 |
# File 'lib/cli/kit/args/definition.rb', line 141 def long @long end |
#short ⇒ Object (readonly)
Returns the value of attribute short.
138 139 140 |
# File 'lib/cli/kit/args/definition.rb', line 138 def short @short end |
Instance Method Details
#as_written_by_user ⇒ Object
144 145 146 |
# File 'lib/cli/kit/args/definition.rb', line 144 def as_written_by_user long ? "--#{long}" : "-#{short}" end |