Class: Errata::Erratum::Transform

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

Constant Summary collapse

ALLOWED_METHODS =
%w{upcase downcase}

Constants inherited from Errata::Erratum

REJECT_ACTIONS, SEMICOLON_DELIMITER, SPECIAL_ABBR

Instance Attribute Summary collapse

Attributes inherited from Errata::Erratum

#matching_expression, #matching_methods, #responder, #section

Instance Method Summary collapse

Methods inherited from Errata::Erratum

#abbr?, #conditions_match?, #expression_matches?, #targets?

Constructor Details

#initialize(responder, options = {}) ⇒ Transform

Returns a new instance of Transform.



8
9
10
11
12
# File 'lib/errata/erratum/transform.rb', line 8

def initialize(responder, options = {})
  super
  @string_method = options[:y]
  raise %{[errata] Method "#{@string_method}" not allowed} unless ALLOWED_METHODS.include? @string_method
end

Instance Attribute Details

#string_methodObject (readonly)

Returns the value of attribute string_method.



6
7
8
# File 'lib/errata/erratum/transform.rb', line 6

def string_method
  @string_method
end

Instance Method Details

#correct!(row) ⇒ Object



14
15
16
17
18
# File 'lib/errata/erratum/transform.rb', line 14

def correct!(row)
  if targets? row
    row[section].gsub!(matching_expression) { |match| match.send string_method }
  end
end