Class: DefMastership::BatchModifier

Inherits:
Object
  • Object
show all
Defined in:
lib/defmastership/batch_modifier.rb

Overview

Change references from temporary to definitive with multiple RefChangers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, adoc_texts) ⇒ BatchModifier

Returns a new instance of BatchModifier.



9
10
11
12
13
# File 'lib/defmastership/batch_modifier.rb', line 9

def initialize(config, adoc_texts)
  @config = config
  @adoc_texts = adoc_texts
  @changes = []
end

Instance Attribute Details

#adoc_textsObject (readonly)

Returns the value of attribute adoc_texts.



7
8
9
# File 'lib/defmastership/batch_modifier.rb', line 7

def adoc_texts
  @adoc_texts
end

#changesObject (readonly)

Returns the value of attribute changes.



7
8
9
# File 'lib/defmastership/batch_modifier.rb', line 7

def changes
  @changes
end

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/defmastership/batch_modifier.rb', line 7

def config
  @config
end

Instance Method Details

#apply(modifs) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/defmastership/batch_modifier.rb', line 15

def apply(modifs)
  modifs.split(/\s*,\s*/).each do |modif|
    modifier = modifier_from(modif)
    @adoc_texts = modifier.do_modifications(@adoc_texts)
    @config[modif.to_sym][:config] = modifier.config
    modifier.changes.each do |change|
      @changes << [modif] + change
    end
  end
end