Class: Errata::Erratum::Simplify
Instance Attribute Summary collapse
#column, #errata, #options
Instance Method Summary
collapse
#conditions_match?, #expression_matches?, #matching_methods, #set_matching_expression
Constructor Details
#initialize(errata, options = {}) ⇒ Simplify
Returns a new instance of Simplify.
6
7
8
9
|
# File 'lib/erratum/simplify.rb', line 6
def initialize(errata, options = {})
super
@second_column = options[:x]
end
|
Instance Attribute Details
#second_column ⇒ Object
Returns the value of attribute second_column.
4
5
6
|
# File 'lib/erratum/simplify.rb', line 4
def second_column
@second_column
end
|
Instance Method Details
#correct!(row) ⇒ Object
19
20
21
22
23
|
# File 'lib/erratum/simplify.rb', line 19
def correct!(row)
super(row) do
row[column].gsub!(matching_expression(row), '')
end
end
|
#inspect ⇒ Object
11
12
13
|
# File 'lib/erratum/simplify.rb', line 11
def inspect
super + " second_column=#{second_column}>"
end
|
#matching_expression(row) ⇒ Object
25
26
27
28
|
# File 'lib/erratum/simplify.rb', line 25
def matching_expression(row)
@_matching_expressions ||= {}
@_matching_expressions[row[second_column]] ||= /[\s\(\[\'\"]*#{Regexp.escape(row[second_column])}[\s\)\]\'\"]*/
end
|
#targets?(row) ⇒ Boolean
15
16
17
|
# File 'lib/erratum/simplify.rb', line 15
def targets?(row)
!row[column].blank? and !row[second_column].blank? and conditions_match?(row) and matching_expression(row).match(row[column])
end
|