Class: Philiprehberger::Approx::RSpecMatchers::BeApproxWithinMatcher Private
- Inherits:
-
Object
- Object
- Philiprehberger::Approx::RSpecMatchers::BeApproxWithinMatcher
- Defined in:
- lib/philiprehberger/approx/rspec_matchers.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #description ⇒ Object private
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
-
#initialize(expected, abs, rel, percent) ⇒ BeApproxWithinMatcher
constructor
private
A new instance of BeApproxWithinMatcher.
- #matches?(actual) ⇒ Boolean private
Constructor Details
#initialize(expected, abs, rel, percent) ⇒ BeApproxWithinMatcher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BeApproxWithinMatcher.
52 53 54 55 56 57 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 52 def initialize(expected, abs, rel, percent) @expected = expected @abs = abs @rel = rel @percent = percent end |
Instance Method Details
#description ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 69 def description "be approximately equal to #{@expected.inspect} (#{tolerance_description})" end |
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 73 def "expected #{@actual.inspect} to be approximately equal to #{@expected.inspect} (#{tolerance_description})" end |
#failure_message_when_negated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 77 def "expected #{@actual.inspect} not to be approximately equal to #{@expected.inspect} (#{tolerance_description})" end |
#matches?(actual) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 63 64 65 66 67 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 59 def matches?(actual) @actual = actual if @percent Approx.percent_equal?(actual, @expected, percent: @percent) else Approx.within?(actual, @expected, abs: @abs, rel: @rel) end end |