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
nilif not found or not unique. - 
  
    
      #unique_flag_negative?  ⇒ Boolean? 
    
    
  
  
  
  
  
  
  
  
  
    
Return whether the unique match was a hit on the negative (
--no-*) case, ornilif not found or not unique. - 
  
    
      #unique_flag_syntax  ⇒ Toys::Flag::Syntax? 
    
    
  
  
  
  
  
  
  
  
  
    
Return the unique Syntax, or
nilif not found or not unique. 
Instance Attribute Details
#string ⇒ String (readonly)
The flag string that was looked up
      187 188 189  | 
    
      # File 'lib/toys/flag.rb', line 187 def string @string end  | 
  
Instance Method Details
#count ⇒ Integer
The number of matches that were found.
      201 202 203  | 
    
      # File 'lib/toys/flag.rb', line 201 def count @flags.size end  | 
  
#found_exact? ⇒ Boolean
Whether an exact match of the string was found
      193 194 195  | 
    
      # File 'lib/toys/flag.rb', line 193 def found_exact? @found_exact end  | 
  
#found_multiple? ⇒ Boolean
Whether multiple matches were found (i.e. ambiguous input).
      225 226 227  | 
    
      # File 'lib/toys/flag.rb', line 225 def found_multiple? @flags.size > 1 end  | 
  
#found_unique? ⇒ Boolean
Whether a single unique match was found.
      209 210 211  | 
    
      # File 'lib/toys/flag.rb', line 209 def found_unique? @flags.size == 1 end  | 
  
#matching_flag_strings ⇒ Array<String>
Returns an array of the matching full flag strings.
      260 261 262 263 264  | 
    
      # File 'lib/toys/flag.rb', line 260 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.
      217 218 219  | 
    
      # File 'lib/toys/flag.rb', line 217 def not_found? @flags.empty? end  | 
  
#unique_flag ⇒ Toys::Flag?
Return the unique Toys::Flag, or nil if not found or
not unique.
      234 235 236  | 
    
      # File 'lib/toys/flag.rb', line 234 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.
      252 253 254  | 
    
      # File 'lib/toys/flag.rb', line 252 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.
      243 244 245  | 
    
      # File 'lib/toys/flag.rb', line 243 def unique_flag_syntax found_unique? ? @flags.first[1] : nil end  |