Class: DataAnon::Strategy::Field::RandomFloatDelta

Inherits:
Object
  • Object
show all
Defined in:
lib/strategy/field/number/random_float_delta.rb

Overview

Shifts the current value randomly within given delta + and -. Default is 10.0

anonymize('points').using FieldStrategy::RandomFloatDelta.new(2.5)

Instance Method Summary collapse

Constructor Details

#initialize(delta = 10.0) ⇒ RandomFloatDelta

Returns a new instance of RandomFloatDelta.



12
13
14
# File 'lib/strategy/field/number/random_float_delta.rb', line 12

def initialize delta = 10.0
  @delta = delta
end

Instance Method Details

#anonymize(field) ⇒ Object



16
17
18
# File 'lib/strategy/field/number/random_float_delta.rb', line 16

def anonymize field
  return field.value + DataAnon::Utils::RandomFloat.generate(-@delta, +@delta)
end