Class: Philiprehberger::Approx::RSpecMatchers::BeApproxMatcher Private

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(expected, epsilon) ⇒ BeApproxMatcher

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 BeApproxMatcher.



27
28
29
30
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 27

def initialize(expected, epsilon)
  @expected = expected
  @epsilon = epsilon
end

Instance Method Details

#descriptionObject

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.



37
38
39
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 37

def description
  "be approximately equal to #{@expected.inspect} (epsilon: #{@epsilon})"
end

#failure_messageObject

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.



41
42
43
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 41

def failure_message
  "expected #{@actual.inspect} to be approximately equal to #{@expected.inspect} (epsilon: #{@epsilon})"
end

#failure_message_when_negatedObject

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.



45
46
47
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 45

def failure_message_when_negated
  "expected #{@actual.inspect} not to be approximately equal to #{@expected.inspect} (epsilon: #{@epsilon})"
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.

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 32

def matches?(actual)
  @actual = actual
  Approx.equal?(actual, @expected, epsilon: @epsilon)
end