class BaconExpect::Matcher::BeWithin
Public Class Methods
new(range)
click to toggle source
# File lib/bacon-expect/matchers/be_within.rb, line 3 def initialize(range) @range = range end
Public Instance Methods
fail!(subject, negated)
click to toggle source
# File lib/bacon-expect/matchers/be_within.rb, line 17 def fail!(subject, negated) raise FailedExpectation.new(FailMessageRenderer.message_for_be_within(negated, subject, @range, @center_value)) end
matches?(subject)
click to toggle source
# File lib/bacon-expect/matchers/be_within.rb, line 12 def matches?(subject) raise InvalidMatcher.new("be_within matcher incomplete. Missing .of value") unless @center_value (subject - @center_value).abs <= @range end
of(center_value)
click to toggle source
# File lib/bacon-expect/matchers/be_within.rb, line 7 def of(center_value) @center_value = center_value self end