Sha256: 31a3449a9b3787593650fe76e45790dea97a7d5e721dc5c90121c72ad884e80e

Contents?: true

Size: 770 Bytes

Versions: 14

Compression:

Stored size: 770 Bytes

Contents

module Roqua
  module Healthy
    class MessageCleaner
      def initialize(message)
        @message = message
      end

      def message
        clean_hash(@message)
      end

      def clean(thing)
        case thing
        when Hash
          clean_hash(thing)
        when Array
          clean_array(thing)
        when String
          clean_string(thing)
        else
          thing
        end
      end

      def clean_hash(hash)
        hash.each do |key, value|
          hash[key] = clean(value)
        end
        hash
      end

      def clean_array(array)
        array.map do |value|
          clean(value)
        end
      end

      def clean_string(string)
        return '' if string == '""'
        string.strip
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
roqua-healthy-1.2.0 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.9 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.8 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.7 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.6 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.5 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.4 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.3 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.2 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.1 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.1.0 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.0.2 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.0.1 lib/roqua/healthy/message_cleaner.rb
roqua-healthy-1.0.0 lib/roqua/healthy/message_cleaner.rb