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)


187
188
189
# File 'lib/toys/flag.rb', line 187

def string
  @string
end

Instance Method Details

#countInteger

The number of matches that were found.

Returns:

  • (Integer)


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

Returns:

  • (Boolean)


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).

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


209
210
211
# File 'lib/toys/flag.rb', line 209

def found_unique?
  @flags.size == 1
end

#matching_flag_stringsArray<String>

Returns an array of the matching full flag strings.

Returns:

  • (Array<String>)


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.

Returns:

  • (Boolean)


217
218
219
# File 'lib/toys/flag.rb', line 217

def not_found?
  @flags.empty?
end

#unique_flagToys::Flag?

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

Returns:



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.

Returns:

  • (Boolean, nil)


252
253
254
# File 'lib/toys/flag.rb', line 252

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:



243
244
245
# File 'lib/toys/flag.rb', line 243

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