Sha256: 7e1127f84b3c58f4e6ddb650dfad97473adf8d0b8bc89e13d0e27510e365b4a8

Contents?: true

Size: 766 Bytes

Versions: 17

Compression:

Stored size: 766 Bytes

Contents

class Errata
  class Erratum
    class Transform < Erratum
      ALLOWED_METHODS = %w{upcase downcase}
      attr_accessor :matching_expression, :string_method
      
      def initialize(errata, options = {})
        super
        set_matching_expression(options)
        @string_method = options[:y]
        raise "string method (#{@string_method}) needs to be in (#{ALLOWED_METHODS.join(', ')})" unless ALLOWED_METHODS.include?(@string_method)
      end
      
      def inspect
        super + " matching_expression=#{matching_expression} string_method=#{string_method}>"
      end
      
      def correct!(row)
        super(row) do
          row[column].gsub!(matching_expression) { |match| match.send(string_method) }
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
seamusabshere-errata-0.1.0 lib/erratum/transform.rb
seamusabshere-errata-0.1.1 lib/erratum/transform.rb
seamusabshere-errata-0.1.2 lib/erratum/transform.rb
seamusabshere-errata-0.1.3 lib/erratum/transform.rb
seamusabshere-errata-0.1.4 lib/erratum/transform.rb
errata-0.2.4 lib/erratum/transform.rb
errata-ruby19-0.2.3 lib/erratum/transform.rb
errata-0.2.3 lib/erratum/transform.rb
errata-0.2.2 lib/erratum/transform.rb
errata-0.2.1 lib/erratum/transform.rb
errata-0.2.0 lib/erratum/transform.rb
errata-0.1.9 lib/erratum/transform.rb
errata-0.1.8 lib/erratum/transform.rb
errata-0.1.7 lib/erratum/transform.rb
errata-0.1.6 lib/erratum/transform.rb
errata-0.1.5 lib/erratum/transform.rb
errata-0.1.4 lib/erratum/transform.rb