Class: Errata::Erratum::Simplify

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

Constant Summary

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?

Constructor Details

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

Returns a new instance of Simplify.


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

def initialize(responder, options = {})
  super
  @second_section = options[:x]
end

Instance Attribute Details

#second_sectionObject (readonly)

Returns the value of attribute second_section


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

def second_section
  @second_section
end

Instance Method Details

#correct!(row) ⇒ Object


15
16
17
18
19
# File 'lib/errata/erratum/simplify.rb', line 15

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

#targets?(row) ⇒ Boolean

Returns:

  • (Boolean)

11
12
13
# File 'lib/errata/erratum/simplify.rb', line 11

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