Sha256: fa190ac2ef347a303612b1fb2f1f2a3bfee4c13fcf2160e7e601427c0ea987cf

Contents?: true

Size: 336 Bytes

Versions: 3

Compression:

Stored size: 336 Bytes

Contents

# frozen_string_literal: true

module OutputConverters
  def to_output_hash(obj)
    if obj.to_s.include? 'Error message'
      obj
    else
      hash = obj.instance_variables.each_with_object({}) do |var, h|
        h[var.to_s.delete('@')] = obj.instance_variable_get(var)
      end
      JSON.pretty_generate(hash)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
emasser-1.0.3 lib/emasser/output_converters.rb
emasser-1.0.1 lib/emasser/output_converters.rb
emasser-1.0.0 lib/emasser/output_converters.rb