Class: Matchi::BeWithin

Inherits:
Object
  • Object
show all
Defined in:
lib/matchi/be_within.rb,
lib/matchi/be_within/of.rb

Overview

Wraps the target of a be_within matcher.

Defined Under Namespace

Classes: Of

Instance Method Summary collapse

Constructor Details

#initialize(delta) ⇒ BeWithin

Initialize a wrapper of the be_within matcher with a numeric value.

Examples:

require "matchi/be_within"

Matchi::BeWithin.new(1)

Parameters:

  • delta (Numeric)

    A numeric value.



16
17
18
# File 'lib/matchi/be_within.rb', line 16

def initialize(delta)
  @delta = delta
end

Instance Method Details

#of(expected) ⇒ #matches?

Specifies an expected numeric value.

Examples:

require "matchi/be_within"

be_within_wrapper = Matchi::BeWithin.new(1)
be_within_wrapper.of(41)

Parameters:

  • expected (Numeric)

    The expected value.

Returns:

  • (#matches?)

    A *be_within of* matcher.



31
32
33
# File 'lib/matchi/be_within.rb', line 31

def of(expected)
  Of.new(@delta, expected)
end