Class: Errata::Erratum::Simplify

Inherits:
Errata::Erratum show all
Defined in:
lib/errata/erratum/simplify.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

Constructor Details

This class inherits a constructor from Errata::Erratum

Instance Method Details

#correct!(row) ⇒ Object



12
13
14
15
16
# File 'lib/errata/erratum/simplify.rb', line 12

def correct!(row)
  if targets? row
    row[section].gsub! special_matcher(row), ''
  end
end

#second_sectionObject



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

def second_section
  options['x']
end

#special_matcher(row) ⇒ Object



18
19
20
# File 'lib/errata/erratum/simplify.rb', line 18

def special_matcher(row)
  /[\s\(\[\'\"]*#{::Regexp.escape(row[second_section])}[\s\)\]\'\"]*/
end

#targets?(row) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/errata/erratum/simplify.rb', line 8

def targets?(row)
  !row[section].blank? and !row[second_section].blank? and conditions_match?(row) and special_matcher(row).match(row[section])
end