Class: Lookout::Inspect

Inherits:
Object show all
Defined in:
lib/lookout-3.0/inspect.rb

Overview

Non-failing inspection of objects. The inspection is encoded for output.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.args(*args) ⇒ String

Returns The inspections of ARGS, separated by “, ”’s.

Parameters:

Returns:

  • (String)

    The inspections of ARGS, separated by “, ”’s



15
16
17
# File 'lib/lookout-3.0/inspect.rb', line 15

def args(*args)
  args.map{ |e| Lookout::Inspect.new(e, 'argument') }.join(', ')
end

Instance Method Details

#callString Also known as: to_s

Returns An UTF-8-encoded String inspection of the given object, generated by invoking #inspect on it, then encoding it as UTF-8, using #dump if any transcoding that may take place fails.

Returns:

  • (String)

    An UTF-8-encoded String inspection of the given object, generated by invoking #inspect on it, then encoding it as UTF-8, using #dump if any transcoding that may take place fails



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lookout-3.0/inspect.rb', line 23

def call
  Lookout::Encode.new(inspection = inspect_object).call
rescue => e
  '(cannot encode inspected %s for output: %s; %s)' %
    [type,
     Lookout::Exception.new(e),
     begin
       'dumping instead: %s' % [inspection.dump]
     rescue => inner
       'dumping also failed: %s' % Lookout::Exception.new(inner)
     end]
end