Class: DocxReplacor::Parser
- Inherits:
-
Object
- Object
- DocxReplacor::Parser
- Defined in:
- lib/docx_replacor/parser.rb
Instance Method Summary collapse
-
#initialize(var_values, text_arrays) ⇒ Parser
constructor
A new instance of Parser.
- #replacement_instructions ⇒ Object
Constructor Details
#initialize(var_values, text_arrays) ⇒ Parser
Returns a new instance of Parser.
7 8 9 10 11 12 13 14 |
# File 'lib/docx_replacor/parser.rb', line 7 def initialize(var_values, text_arrays) @instructions = [] @full_variables = [] @partial_variables = [] @text_arrays = text_arrays @var_values = transform_keys(var_values.with_indifferent_access) @variables = @var_values.keys.map(&:to_s) end |
Instance Method Details
#replacement_instructions ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/docx_replacor/parser.rb', line 16 def replacement_instructions @text_arrays.each_with_index do |text, index| extract_full_variables(text, index) extract_partial_variables(text, index) end build_instructions_for_partial_variables @instructions end |