Class: I18nFlow::Splitter::Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_flow/splitter/strategy.rb

Constant Summary collapse

DEFAULT_MAX_LEVEL =
3
DEFAULT_LINE_THRESHOLD =
50

Instance Method Summary collapse

Constructor Details

#initialize(ast, max_level: DEFAULT_MAX_LEVEL, line_threshold: DEFAULT_LINE_THRESHOLD) ⇒ Strategy

Returns a new instance of Strategy.



6
7
8
9
10
11
12
13
14
# File 'lib/i18n_flow/splitter/strategy.rb', line 6

def initialize(
  ast,
  max_level:      DEFAULT_MAX_LEVEL,
  line_threshold: DEFAULT_LINE_THRESHOLD
)
  @ast            = ast
  @max_level      = max_level
  @line_threshold = line_threshold
end

Instance Method Details

#chunksObject



21
22
23
# File 'lib/i18n_flow/splitter/strategy.rb', line 21

def chunks
  @chunks ||= Hash.new { |h, k| h[k] = [] }
end

#split!Object



16
17
18
19
# File 'lib/i18n_flow/splitter/strategy.rb', line 16

def split!
  @chunks = nil
  traverse(@ast, level: 0)
end