Class: Errata::Erratum::Replace

Inherits:
Errata::Erratum show all
Defined in:
lib/errata/erratum/replace.rb

Instance Attribute Summary

Attributes inherited from Errata::Erratum

#errata, #options

Instance Method Summary collapse

Methods inherited from Errata::Erratum

#conditions_match?, #expression_matches?, #initialize, #matching_expression, #matching_methods, #responder, #section, #targets?

Constructor Details

This class inherits a constructor from Errata::Erratum

Instance Method Details

#correct!(row) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'lib/errata/erratum/replace.rb', line 8

def correct!(row)
  if targets? row
    if matching_expression.blank?
      row[section] = correction.dup
    else
      row[section].gsub! matching_expression, correction
    end
  end
end

#correctionObject


4
5
6
# File 'lib/errata/erratum/replace.rb', line 4

def correction
  @correction ||= /\Aabbr\((.*)\)\z/.match(options['x']) ? '\1' + options['y'].to_s + '\2' : options['y'].to_s
end