Sha256: 3ce5e3e35b78ec9c54ac179ffee38dc70a80d162a59516c080b36751ad82fe23

Contents?: true

Size: 501 Bytes

Versions: 7

Compression:

Stored size: 501 Bytes

Contents

module Cotcube
  module Helpers

    def instance_inspect(obj, keylength: 20, &block)
      obj.instance_variables.map do |var| 
        if block_given?
          block.call(var, obj.instance_variable_get(var))
        else
          puts "#{format "%-#{keylength}s", var
                         }: #{obj.instance_variable_get(var).inspect.scan(/.{1,120}/).join( "\n" + ' '*(keylength+2)) 
                         }" 
        end
      end
    end

    module_function :instance_inspect

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cotcube-helpers-0.2.4 lib/cotcube-helpers/output.rb
cotcube-helpers-0.2.3 lib/cotcube-helpers/output.rb
cotcube-helpers-0.2.2.5 lib/cotcube-helpers/output.rb
cotcube-helpers-0.2.2.4 lib/cotcube-helpers/output.rb
cotcube-helpers-0.2.2.3 lib/cotcube-helpers/output.rb
cotcube-helpers-0.2.1.1 lib/cotcube-helpers/output.rb
cotcube-helpers-0.2.0 lib/cotcube-helpers/output.rb