Class: Errata::Erratum::Replace
- Inherits:
-
Errata::Erratum
- Object
- Errata::Erratum
- Errata::Erratum::Replace
- Defined in:
- lib/errata/erratum/replace.rb
Constant Summary
Constants inherited from Errata::Erratum
REJECT_ACTIONS, SEMICOLON_DELIMITER, SPECIAL_ABBR
Instance Attribute Summary collapse
-
#correction ⇒ Object
readonly
Returns the value of attribute correction.
Attributes inherited from Errata::Erratum
#matching_expression, #matching_methods, #responder, #section
Instance Method Summary collapse
- #correct!(row) ⇒ Object
-
#initialize(responder, options = {}) ⇒ Replace
constructor
A new instance of Replace.
Methods inherited from Errata::Erratum
#abbr?, #conditions_match?, #expression_matches?, #targets?
Constructor Details
#initialize(responder, options = {}) ⇒ Replace
Returns a new instance of Replace.
6 7 8 9 10 11 12 13 |
# File 'lib/errata/erratum/replace.rb', line 6 def initialize(responder, = {}) super @correction = if abbr? '\1' + [:y].to_s + '\2' else [:y].to_s end end |
Instance Attribute Details
#correction ⇒ Object (readonly)
Returns the value of attribute correction.
4 5 6 |
# File 'lib/errata/erratum/replace.rb', line 4 def correction @correction end |
Instance Method Details
#correct!(row) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/errata/erratum/replace.rb', line 15 def correct!(row) if targets? row if matching_expression.blank? row[section] = correction.dup else row[section].gsub! matching_expression, correction end end end |