Class: DataAnon::Strategy::Field::RandomBigDecimalDelta

Inherits:
Object
  • Object
show all
Defined in:
lib/strategy/field/number/random_big_decimal_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 = 100.0) ⇒ RandomBigDecimalDelta

Returns a new instance of RandomBigDecimalDelta.


14
15
16
# File 'lib/strategy/field/number/random_big_decimal_delta.rb', line 14

def initialize delta = 100.0
  @delta = delta
end

Instance Method Details

#anonymize(field) ⇒ Object


18
19
20
# File 'lib/strategy/field/number/random_big_decimal_delta.rb', line 18

def anonymize field
  return BigDecimal.new("#{field.value + DataAnon::Utils::RandomFloat.generate([email protected], [email protected])}")
end