Sha256: e6569762478e2764c5e7d378000f92e452dad4a945d7e6a7d5759d253c27c3c6

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

# frozen_string_literal: true

require_relative File.join("be_within", "of")

module Matchi
  # Wraps the target of a be_within matcher.
  class BeWithin
    # Initialize a wrapper of the be_within matcher with a numeric value.
    #
    # @example
    #   require "matchi/be_within"
    #
    #   Matchi::BeWithin.new(1)
    #
    # @param delta [Numeric] A numeric value.
    def initialize(delta)
      @delta = delta
    end

    # Specifies an expected numeric value.
    #
    # @example
    #   require "matchi/be_within"
    #
    #   be_within_wrapper = Matchi::BeWithin.new(1)
    #   be_within_wrapper.of(41)
    #
    # @param expected [Numeric] The expected value.
    #
    # @return [#matches?] A *be_within of* matcher.
    def of(expected)
      Of.new(@delta, expected)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
matchi-3.3.2 lib/matchi/be_within.rb
matchi-3.3.1 lib/matchi/be_within.rb
matchi-3.3.0 lib/matchi/be_within.rb
matchi-3.2.0 lib/matchi/be_within.rb