Sha256: 901d8f2c78b2435652671d49cb6be0aca679cddf34492f52431f6ebe5d091222

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

Stored size: 758 Bytes

Contents

# frozen_string_literal: true

module Fear
  module Extractor
    # Part of recursive array matcher. Match against its head.
    # @see ArrayMatcher
    class ArrayHeadMatcher < Matcher
      # @!attribute matcher
      #   @return [Matcher]
      # @!attribute index
      #   @return [Types::Strict::Integer]

      # @param other [<>]
      def defined_at?(other)
        if other.empty?
          false
        else
          matcher.defined_at?(other.first)
        end
      end

      # @param other [<>]
      def bindings(other)
        if other.empty?
          super
        else
          matcher.bindings(other.first)
        end
      end

      def failure_reason(other)
        matcher.failure_reason(other.first)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fear-1.2.0 lib/fear/extractor/array_head_matcher.rb
fear-1.1.0 lib/fear/extractor/array_head_matcher.rb