Module: Olyx::Guardrails::Text::MappedBuilder

Defined in:
lib/olyx/guardrails/text/mapped_builder.rb

Overview

Builds normalized text with indexes back to the original String.

Class Method Summary collapse

Class Method Details

.call(source) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/olyx/guardrails/text/mapped_builder.rb', line 12

def call(source)
  text = +''
  starts = []
  endings = []
  source.each_char.with_index do |character, index|
    append(text, starts, endings, Normalizer.normalize_character(character), index)
  end
  [text, starts.freeze, endings.freeze]
end