The project is in a healthy, maintained state
Get `#inspect` without `exception` and `nil` possibilities
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies
 Project Readme

string-safe_inspector

Build Status Gem Version

Get #inspect without exception and nil possibilities

Usage

Require Ruby 2.6 or later

Add below code into your Gemfile

gem 'string-safe_inspector', '>= 0.0.1', '< 0.1.0'

Overview

require 'string/safe_inspector'

does_not_have_inspect = BasicObject.new; nil

begin
  p does_not_have_inspect
rescue => err
  p err
end
#=> #<NoMethodError: undefined method `inspect' for #<BasicObject:0x00007fd1500fa680>>

String::SafeInspector.inspect_for(does_not_have_inspect)
#=>  "#<BasicObject:0x00007fd1500fa680>"

Links