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
# File 'lib/rbs/test/guaranteed.rb', line 11

module_function def guaranteed_inspect(obj)
  obj.inspect
rescue NoMethodError
  INSPECT.bind_call(obj)
end

Instance Method Details

#inspectObject



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

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

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

  string.concat '>'
end