Class: Toys::Flag::Resolution
- Inherits:
-
Object
- Object
- Toys::Flag::Resolution
- Defined in:
- lib/toys/flag.rb
Overview
The result of looking up a flag by name.
Instance Attribute Summary collapse
-
#string ⇒ String
readonly
The flag string that was looked up.
Instance Method Summary collapse
-
#count ⇒ Integer
The number of matches that were found.
-
#found_exact? ⇒ Boolean
Whether an exact match of the string was found.
-
#found_multiple? ⇒ Boolean
Whether multiple matches were found (i.e. ambiguous input).
-
#found_unique? ⇒ Boolean
Whether a single unique match was found.
-
#matching_flag_strings ⇒ Array<String>
Returns an array of the matching full flag strings.
-
#not_found? ⇒ Boolean
Whether no matches were found.
-
#unique_flag ⇒ Toys::Flag?
Return the unique Toys::Flag, or
nil
if not found or not unique. -
#unique_flag_negative? ⇒ Boolean?
Return whether the unique match was a hit on the negative (
--no-*
) case, ornil
if not found or not unique. -
#unique_flag_syntax ⇒ Toys::Flag::Syntax?
Return the unique Syntax, or
nil
if not found or not unique.
Instance Attribute Details
#string ⇒ String (readonly)
The flag string that was looked up
621 622 623 |
# File 'lib/toys/flag.rb', line 621 def string @string end |
Instance Method Details
#count ⇒ Integer
The number of matches that were found.
635 636 637 |
# File 'lib/toys/flag.rb', line 635 def count @flags.size end |
#found_exact? ⇒ Boolean
Whether an exact match of the string was found
627 628 629 |
# File 'lib/toys/flag.rb', line 627 def found_exact? @found_exact end |
#found_multiple? ⇒ Boolean
Whether multiple matches were found (i.e. ambiguous input).
659 660 661 |
# File 'lib/toys/flag.rb', line 659 def found_multiple? @flags.size > 1 end |
#found_unique? ⇒ Boolean
Whether a single unique match was found.
643 644 645 |
# File 'lib/toys/flag.rb', line 643 def found_unique? @flags.size == 1 end |
#matching_flag_strings ⇒ Array<String>
Returns an array of the matching full flag strings.
694 695 696 697 698 |
# File 'lib/toys/flag.rb', line 694 def matching_flag_strings @flags.map do |_flag, flag_syntax, negative| negative ? flag_syntax.negative_flag : flag_syntax.positive_flag end end |
#not_found? ⇒ Boolean
Whether no matches were found.
651 652 653 |
# File 'lib/toys/flag.rb', line 651 def not_found? @flags.empty? end |
#unique_flag ⇒ Toys::Flag?
Return the unique Toys::Flag, or nil
if not found or
not unique.
668 669 670 |
# File 'lib/toys/flag.rb', line 668 def unique_flag found_unique? ? @flags.first[0] : nil end |
#unique_flag_negative? ⇒ Boolean?
Return whether the unique match was a hit on the negative (--no-*
)
case, or nil
if not found or not unique.
686 687 688 |
# File 'lib/toys/flag.rb', line 686 def unique_flag_negative? found_unique? ? @flags.first[2] : nil end |
#unique_flag_syntax ⇒ Toys::Flag::Syntax?
Return the unique Syntax, or nil
if not found
or not unique.
677 678 679 |
# File 'lib/toys/flag.rb', line 677 def unique_flag_syntax found_unique? ? @flags.first[1] : nil end |