Class: Git::Commands::OperandAllocator Private
- Inherits:
-
Object
- Object
- Git::Commands::OperandAllocator
- 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.
Allocates operand (positional argument) values to definitions following Ruby semantics.
This class handles the complex logic of mapping positional values to their definitions, supporting required, optional, and repeatable operands.
Defined Under Namespace
Classes: LeadingAllocationState
Instance Method Summary collapse
-
#allocate(values) ⇒ Array(Hash, Integer)
private
Allocate values to definitions.
-
#initialize(definitions) ⇒ OperandAllocator
constructor
private
A new instance of OperandAllocator.
Constructor Details
#initialize(definitions) ⇒ OperandAllocator
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 OperandAllocator.
4161 4162 4163 |
# File 'lib/git/commands/arguments.rb', line 4161 def initialize(definitions) @definitions = definitions end |
Instance Method Details
#allocate(values) ⇒ Array(Hash, 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.
Allocate values to definitions
4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 |
# File 'lib/git/commands/arguments.rb', line 4170 def allocate(values) allocation = {} repeatable_index = @definitions.find_index { |d| d[:repeatable] } consumed = if repeatable_index.nil? allocate_without_repeatable(values, allocation) else allocate_with_repeatable(values, allocation, repeatable_index) end [allocation, consumed] end |