Class: Toys::Flag::Resolution

Inherits:
Object
  • Object
show all
Defined in:
toys-core/lib/toys/flag.rb

Overview

Defined in the toys-core gem

The result of looking up a flag by name.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stringString (readonly)

The flag string that was looked up

Returns:

  • (String)


623
624
625
# File 'toys-core/lib/toys/flag.rb', line 623

def string
  @string
end

Instance Method Details

#countInteger

The number of matches that were found.

Returns:

  • (Integer)


637
638
639
# File 'toys-core/lib/toys/flag.rb', line 637

def count
  @flags.size
end

#found_exact?Boolean

Whether an exact match of the string was found

Returns:

  • (Boolean)


629
630
631
# File 'toys-core/lib/toys/flag.rb', line 629

def found_exact?
  @found_exact
end

#found_multiple?Boolean

Whether multiple matches were found (i.e. ambiguous input).

Returns:

  • (Boolean)


661
662
663
# File 'toys-core/lib/toys/flag.rb', line 661

def found_multiple?
  @flags.size > 1
end

#found_unique?Boolean

Whether a single unique match was found.

Returns:

  • (Boolean)


645
646
647
# File 'toys-core/lib/toys/flag.rb', line 645

def found_unique?
  @flags.size == 1
end

#matching_flag_stringsArray<String>

Returns an array of the matching full flag strings.

Returns:

  • (Array<String>)


696
697
698
699
700
# File 'toys-core/lib/toys/flag.rb', line 696

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.

Returns:

  • (Boolean)


653
654
655
# File 'toys-core/lib/toys/flag.rb', line 653

def not_found?
  @flags.empty?
end

#unique_flagToys::Flag?

Return the unique Toys::Flag, or nil if not found or not unique.

Returns:



670
671
672
# File 'toys-core/lib/toys/flag.rb', line 670

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.

Returns:

  • (Boolean, nil)


688
689
690
# File 'toys-core/lib/toys/flag.rb', line 688

def unique_flag_negative?
  found_unique? ? @flags.first[2] : nil
end

#unique_flag_syntaxToys::Flag::Syntax?

Return the unique Syntax, or nil if not found or not unique.

Returns:



679
680
681
# File 'toys-core/lib/toys/flag.rb', line 679

def unique_flag_syntax
  found_unique? ? @flags.first[1] : nil
end