Class: ActiveRecordPolyline::Compaction::RandomCompressor

Inherits:
Base
  • Object
show all
Defined in:
lib/active_record_polyline/compaction/random_compressor.rb

Instance Method Summary collapse

Methods inherited from Base

#apply, compress_after_push, compress_before_push, #push

Constructor Details

#initialize(ratio: 0.5) ⇒ RandomCompressor

Returns a new instance of RandomCompressor.



6
7
8
# File 'lib/active_record_polyline/compaction/random_compressor.rb', line 6

def initialize(ratio: 0.5)
  @ratio = ratio
end

Instance Method Details

#addable?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/active_record_polyline/compaction/random_compressor.rb', line 10

def addable?(*)
  rand < @ratio
end