Class: Errata::Erratum
- Inherits:
-
Object
- Object
- Errata::Erratum
- Defined in:
- lib/erratum.rb,
lib/erratum/delete.rb,
lib/erratum/reject.rb,
lib/erratum/replace.rb,
lib/erratum/simplify.rb,
lib/erratum/truncate.rb,
lib/erratum/transform.rb
Defined Under Namespace
Classes: Delete, Reject, Replace, Simplify, Transform, Truncate
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#errata ⇒ Object
Returns the value of attribute errata.
-
#matching_method ⇒ Object
Returns the value of attribute matching_method.
Instance Method Summary collapse
- #correct!(row, &block) ⇒ Object
-
#initialize(errata, options = {}) ⇒ Erratum
constructor
A new instance of Erratum.
- #inspect ⇒ Object
- #targets?(row) ⇒ Boolean
Constructor Details
#initialize(errata, options = {}) ⇒ Erratum
Returns a new instance of Erratum.
6 7 8 9 10 11 |
# File 'lib/erratum.rb', line 6 def initialize(errata, = {}) raise "you can't set this from outside" if .has_key?(:prefix) @errata = errata @column = [:section] @matching_method = "#{options[:condition].gsub(/[^a-z0-9]/i, '_').downcase}?".to_sym if [:condition] end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
3 4 5 |
# File 'lib/erratum.rb', line 3 def column @column end |
#errata ⇒ Object
Returns the value of attribute errata.
3 4 5 |
# File 'lib/erratum.rb', line 3 def errata @errata end |
#matching_method ⇒ Object
Returns the value of attribute matching_method.
3 4 5 |
# File 'lib/erratum.rb', line 3 def matching_method @matching_method end |
Instance Method Details
#correct!(row, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/erratum.rb', line 21 def correct!(row, &block) return :skipped unless targets?(row) # old_value = row[column].to_s.dup yield if block_given? # unless name.demodulize.underscore == 'truncate' or name.demodulize.underscore == 'simplify' # puts "-" * 64 # puts inspect # puts row.inspect # if row[column] != old_value # puts "#{old_value} -> #{row[column]}" # else # puts "no change" # end # puts # end :corrected end |
#inspect ⇒ Object
13 14 15 |
# File 'lib/erratum.rb', line 13 def inspect "<#{self.class.name}:#{object_id} klass=#{klass.name} column=#{column} matching_method=#{matching_method}" end |
#targets?(row) ⇒ Boolean
17 18 19 |
# File 'lib/erratum.rb', line 17 def targets?(row) !!(method_matches?(row) and expression_matches?(row)) end |