Class: Errata::Erratum::Transform
- Inherits:
-
Errata::Erratum
- Object
- Errata::Erratum
- Errata::Erratum::Transform
- Defined in:
- lib/erratum/transform.rb
Constant Summary collapse
- ALLOWED_METHODS =
%w{upcase downcase}
Instance Attribute Summary collapse
-
#matching_expression ⇒ Object
Returns the value of attribute matching_expression.
-
#string_method ⇒ Object
Returns the value of attribute string_method.
Attributes inherited from Errata::Erratum
Instance Method Summary collapse
- #correct!(row) ⇒ Object
-
#initialize(errata, options = {}) ⇒ Transform
constructor
A new instance of Transform.
- #inspect ⇒ Object
Methods inherited from Errata::Erratum
#conditions_match?, #expression_matches?, #matching_methods, #set_matching_expression, #targets?
Constructor Details
#initialize(errata, options = {}) ⇒ Transform
Returns a new instance of Transform.
7 8 9 10 11 12 |
# File 'lib/erratum/transform.rb', line 7 def initialize(errata, = {}) super set_matching_expression() @string_method = [:y] raise "string method (#{@string_method}) needs to be in (#{ALLOWED_METHODS.join(', ')})" unless ALLOWED_METHODS.include?(@string_method) end |
Instance Attribute Details
#matching_expression ⇒ Object
Returns the value of attribute matching_expression.
5 6 7 |
# File 'lib/erratum/transform.rb', line 5 def matching_expression @matching_expression end |
#string_method ⇒ Object
Returns the value of attribute string_method.
5 6 7 |
# File 'lib/erratum/transform.rb', line 5 def string_method @string_method end |
Instance Method Details
#correct!(row) ⇒ Object
18 19 20 21 22 |
# File 'lib/erratum/transform.rb', line 18 def correct!(row) super(row) do row[column].gsub!(matching_expression) { |match| match.send(string_method) } end end |
#inspect ⇒ Object
14 15 16 |
# File 'lib/erratum/transform.rb', line 14 def inspect super + " matching_expression=#{matching_expression} string_method=#{string_method}>" end |