Class: ApproximateValue

Inherits:
Object
  • Object
show all
Defined in:
lib/test_ish.rb

Instance Method Summary collapse

Constructor Details

#initialize(me, acceptable_delta) ⇒ ApproximateValue

Returns a new instance of ApproximateValue.



9
10
11
12
# File 'lib/test_ish.rb', line 9

def initialize(me, acceptable_delta)
  @me = me
  @acceptable_delta = acceptable_delta
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
# File 'lib/test_ish.rb', line 14

def ==(other)
  (other - @me).abs < @acceptable_delta
end

#to_sObject



18
19
20
# File 'lib/test_ish.rb', line 18

def to_s
  "within #{@acceptable_delta} of #{@me}"
end