Class: Matchi::BeWithin
- Inherits:
-
Object
- Object
- Matchi::BeWithin
- Defined in:
- lib/matchi/be_within.rb,
lib/matchi/be_within/of.rb
Overview
Builder for the be within DELTA of EXPECTED matcher. It is not a matcher
itself: it does not respond to match?, so a framework that checks the
matcher interface rejects a forgotten of.
Defined Under Namespace
Classes: Of
Instance Method Summary collapse
-
#initialize(delta) ⇒ BeWithin
constructor
A new instance of BeWithin.
-
#of(expected) ⇒ Matchi::BeWithin::Of
The matcher.
- #to_s ⇒ String
Constructor Details
#initialize(delta) ⇒ BeWithin
Returns a new instance of BeWithin.
16 17 18 |
# File 'lib/matchi/be_within.rb', line 16 def initialize(delta) @delta = Number.non_negative!(delta, "delta") end |
Instance Method Details
#of(expected) ⇒ Matchi::BeWithin::Of
Returns the matcher.
23 24 25 |
# File 'lib/matchi/be_within.rb', line 23 def of(expected) Of.new(@delta, expected) end |
#to_s ⇒ String
28 29 30 |
# File 'lib/matchi/be_within.rb', line 28 def to_s "be within #{@delta.inspect}" end |