Class: Git::Commands::OperandAllocator::LeadingAllocationState Private
- Inherits:
-
Object
- Object
- Git::Commands::OperandAllocator::LeadingAllocationState
- Defined in:
- lib/git/commands/arguments.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Encapsulates state for allocating leading positionals
Instance Method Summary collapse
-
#allocate(allocation) ⇒ Integer
private
Allocates leading positional values and returns consumed non-nil count.
-
#initialize(definitions, values, required_check) ⇒ LeadingAllocationState
constructor
private
A new instance of LeadingAllocationState.
Constructor Details
#initialize(definitions, values, required_check) ⇒ LeadingAllocationState
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of LeadingAllocationState.
3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 |
# File 'lib/git/commands/arguments.rb', line 3454 def initialize(definitions, values, required_check) @definitions = definitions @values = values @required_check = required_check @required_count = definitions.count { |d| required_check.call(d) } @extra_for_optionals = [values.size - @required_count, 0].max @val_idx = 0 @opt_idx = 0 @consumed = 0 end |
Instance Method Details
#allocate(allocation) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Allocates leading positional values and returns consumed non-nil count
3471 3472 3473 3474 |
# File 'lib/git/commands/arguments.rb', line 3471 def allocate(allocation) @definitions.each { |definition| allocate_one(allocation, definition) } @consumed end |