Exception: RakeCommander::Options::ErrorRely
- Inherits:
-
StandardError
- Object
- StandardError
- RakeCommander::Options::ErrorRely
- Extended by:
- Name
- Defined in:
- lib/rake-commander/options/error_rely.rb
Overview
Relies between OptionParser and RakeCommander errors
Direct Known Subclasses
Constant Summary collapse
- OPTION_REGEX =
/(?:argument|option): (?<option>.+)/i.freeze
Constants included from Name
Name::DOUBLE_HYPHEN_REGEX, Name::HYPEN_REGEX, Name::HYPHEN_START_REGEX, Name::OPTIONAL_REGEX, Name::SINGLE_HYPHEN_REGEX, Name::SPACE_REGEX, Name::UNDERSCORE_REGEX
Instance Method Summary collapse
-
#initialize(value) ⇒ ErrorRely
constructor
A new instance of ErrorRely.
- #name? ⇒ Boolean
- #option_sym ⇒ Object
- #short? ⇒ Boolean
Methods included from Name
argument_optional?, argument_required?, double_hyphen?, name_argument, name_argument?, name_hyphen, name_hyphen?, name_sym, name_word_sym, short_hyphen, short_hyphen?, short_sym, single_hyphen?, valid_name?, valid_short?
Constructor Details
#initialize(value) ⇒ ErrorRely
Returns a new instance of ErrorRely.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rake-commander/options/error_rely.rb', line 9 def initialize(value) case value when OptionParser::MissingArgument, OptionParser::InvalidArgument super(value.) when String super(value) else raise ArgumentError, "Expecting String or OptionParser error. Given: #{value.class}" end end |
Instance Method Details
#name? ⇒ Boolean
20 21 22 |
# File 'lib/rake-commander/options/error_rely.rb', line 20 def name? option_sym.to_s.length > 1 end |
#option_sym ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rake-commander/options/error_rely.rb', line 28 def option_sym return @option_sym if @option_sym return nil unless match = .match(self.class::OPTION_REGEX) option = match[:option] @option_sym = \ if option.length > 1 self.class.name_word_sym(option) else self.class.short_sym(option) end end |
#short? ⇒ Boolean
24 25 26 |
# File 'lib/rake-commander/options/error_rely.rb', line 24 def short? option_sym.to_s.length == 1 end |