Class: Toys::Flag::Resolution

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

Overview

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)


617
618
619
# File 'lib/toys/flag.rb', line 617

def string
  @string
end

Instance Method Details

#countInteger

The number of matches that were found.

Returns:

  • (Integer)


631
632
633
# File 'lib/toys/flag.rb', line 631

def count
  @flags.size
end

#found_exact?Boolean

Whether an exact match of the string was found

Returns:

  • (Boolean)


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

def found_exact?
  @found_exact
end

#found_multiple?Boolean

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

Returns:

  • (Boolean)


655
656
657
# File 'lib/toys/flag.rb', line 655

def found_multiple?
  @flags.size > 1
end

#found_unique?Boolean

Whether a single unique match was found.

Returns:

  • (Boolean)


639
640
641
# File 'lib/toys/flag.rb', line 639

def found_unique?
  @flags.size == 1
end

#matching_flag_stringsArray<String>

Returns an array of the matching full flag strings.

Returns:

  • (Array<String>)


690
691
692
693
694
# File 'lib/toys/flag.rb', line 690

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)


647
648
649
# File 'lib/toys/flag.rb', line 647

def not_found?
  @flags.empty?
end

#unique_flagToys::Flag?

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

Returns:



664
665
666
# File 'lib/toys/flag.rb', line 664

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)


682
683
684
# File 'lib/toys/flag.rb', line 682

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:



673
674
675
# File 'lib/toys/flag.rb', line 673

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