Class: Errata::Erratum::Replace
- Inherits:
-
Errata::Erratum
- Object
- Errata::Erratum
- Errata::Erratum::Replace
- Defined in:
- lib/erratum/replace.rb
Instance Attribute Summary collapse
-
#correction ⇒ Object
Returns the value of attribute correction.
-
#matching_expression ⇒ Object
Returns the value of attribute matching_expression.
Attributes inherited from Errata::Erratum
Instance Method Summary collapse
- #correct!(row) ⇒ Object
-
#initialize(errata, options = {}) ⇒ Replace
constructor
A new instance of Replace.
- #inspect ⇒ Object
Methods inherited from Errata::Erratum
#conditions_match?, #expression_matches?, #matching_methods, #set_matching_expression, #targets?
Constructor Details
#initialize(errata, options = {}) ⇒ Replace
6 7 8 9 10 |
# File 'lib/erratum/replace.rb', line 6 def initialize(errata, = {}) super set_matching_expression() @correction = /\Aabbr\((.*)\)\z/.match([:x]) ? '\1' + [:y].to_s + '\2' : [:y].to_s end |
Instance Attribute Details
#correction ⇒ Object
Returns the value of attribute correction.
4 5 6 |
# File 'lib/erratum/replace.rb', line 4 def correction @correction end |
#matching_expression ⇒ Object
Returns the value of attribute matching_expression.
4 5 6 |
# File 'lib/erratum/replace.rb', line 4 def matching_expression @matching_expression end |
Instance Method Details
#correct!(row) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/erratum/replace.rb', line 16 def correct!(row) super(row) do if matching_expression.blank? row[column] = correction else row[column].gsub!(matching_expression, correction) end end end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/erratum/replace.rb', line 12 def inspect super + " matching_expression=#{matching_expression} correction=#{correction}>" end |