Sha256: baec5a8f5017c9e2febd963e430fe51c2d242c0fc875b450d1edf2367cf5d471

Contents?: true

Size: 660 Bytes

Versions: 4

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

module Leftovers
  module ProcessorBuilders
    module Keyword
      def self.build(value, then_processor)
        return unless value

        then_processor = case value
        when true, '**' then then_processor
        when ::String, ::Hash, ::Array
          ::Leftovers::Processors::MatchCurrentNode.new(
            ::Leftovers::MatcherBuilders::NodeName.build(value), then_processor
          )
        # :nocov:
        else raise Leftovers::UnexpectedCase, "Unhandled value #{value.inspect}"
          # :nocov:
        end

        ::Leftovers::Processors::EachKeyword.new(then_processor)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
leftovers-0.11.1 lib/leftovers/processor_builders/keyword.rb
leftovers-0.11.0 lib/leftovers/processor_builders/keyword.rb
leftovers-0.10.0 lib/leftovers/processor_builders/keyword.rb
leftovers-0.9.0 lib/leftovers/processor_builders/keyword.rb