Class: TranslationDiff::Batch::Filler

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

Overview

Fills one batch until its count or its cumulative escaped size would cross the limit, then starts the next.

Instance Method Summary collapse

Constructor Details

#initialize(capabilities) ⇒ Filler

Returns a new instance of Filler.



40
41
42
43
44
45
# File 'lib/translation_diff/batch.rb', line 40

def initialize(capabilities)
  @capabilities = capabilities
  @batches = []
  @current = []
  @current_size = 0
end

Instance Method Details

#add(segment) ⇒ Object



47
48
49
50
51
52
# File 'lib/translation_diff/batch.rb', line 47

def add(segment)
  size = escaped_size(segment)
  flush if full?(size)
  @current << segment
  @current_size += size
end

#batches ⇒ Object



54
55
56
57
# File 'lib/translation_diff/batch.rb', line 54

def batches
  flush
  @batches
end