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.
65 66 67 68 69 70 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 65 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.
82 83 84 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 82 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.
86 87 88 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 86 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.
90 91 92 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 90 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.
72 73 74 75 76 77 78 79 80 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 72 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 |