Module: Leftovers::ProcessorBuilders::Argument
- Defined in:
- lib/leftovers/processor_builders/argument.rb
Class Method Summary collapse
-
.build(patterns, processor) ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.build(patterns, processor) ⇒ Object
rubocop:disable Metrics/MethodLength
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/leftovers/processor_builders/argument.rb', line 7 def build(patterns, processor) # rubocop:disable Metrics/MethodLength Each.each_or_self(patterns) do |pat| case pat when ::Integer then Processors::PositionalArgument.new(pat, processor) when '*' then Processors::EachPositionalArgument.new(processor) when '**' then Processors::EachKeywordArgument.new(processor) when /\A(\d+)\+\z/ then Processors::EachPositionalArgumentFrom.new(pat.to_i, processor) when ::String then KeywordArgument.build(pat, processor) when ::Hash then build_hash(processor, pat) # :nocov: else raise UnexpectedCase, "Unhandled value #{pat.inspect}" # :nocov: end end end |