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)
constructor
private
Initialize allocation state for the given leading definitions and values.
Constructor Details
#initialize(definitions, values, required_check)
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.
Initialize allocation state for the given leading definitions and values
4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 |
# File 'lib/git/commands/arguments.rb', line 4431 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
4448 4449 4450 4451 |
# File 'lib/git/commands/arguments.rb', line 4448 def allocate(allocation) @definitions.each { |definition| allocate_one(allocation, definition) } @consumed end |