Sha256: 0d82d864c85491b5adb0a6f6e9df1747831bac2c91906586e5a921074902cf49
Contents?: true
Size: 967 Bytes
Versions: 3
Compression:
Stored size: 967 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) raise ::ArgumentError, "delta must be a Numeric" unless delta.is_a?(::Numeric) raise ::ArgumentError, "delta must be non-negative" if delta.negative? @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 [#match?] A *be_within of* matcher. def of(expected) Of.new(@delta, expected) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
matchi-4.1.1 | lib/matchi/be_within.rb |
matchi-4.1.0 | lib/matchi/be_within.rb |
matchi-4.0.0 | lib/matchi/be_within.rb |