Module: RBS::Test::Guaranteed::Inspect

Included in:
ArgumentsReturn
Defined in:
lib/rbs/test/guaranteed.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.guaranteed_inspect(obj) ⇒ Object



11
12
13
14
15
16
# File 'lib/rbs/test/guaranteed.rb', line 11

module_function def guaranteed_inspect(obj)
  obj.inspect
rescue NoMethodError => err
  raise unless err.name == :inspect && EQUAL.bind_call(obj, err.receiver)
  INSPECT.bind_call(obj)
end

Instance Method Details

#inspectObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/rbs/test/guaranteed.rb', line 18

def inspect
  string = "<#{self.class.name}:"

  instance_variables.each_with_index do |variable, index|
    string.concat ', ' unless index.zero?
    string.concat "#{variable}: #{guaranteed_inspect(variable)}"
  end

  string.concat '>'
end