Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/pretty_inspect.rb
Overview
Pretty Inspect Gem
Instance Method Summary collapse
-
#pretty_inspect(max_level = 999) ⇒ Object
This gem extends Object::inspect to “pretty” inspect arrays and hashes.
Instance Method Details
#pretty_inspect(max_level = 999) ⇒ Object
This gem extends Object::inspect to “pretty” inspect
arrays and hashes.
Example: (copy this to irb)
require 'pretty_inspect'
require 'bigdecimal'
class X
def initialize
@y = BigDecimal(31.41592653589796,4)
@f = false
@t = true
@g = 3.141592653589796
@n = nil
end
end
puts (['a','b',{1=>'a',2=>X.new},'c'].pretty_inspect)
Yields:
[
"a",
"b",
{
1=>"a",
2=><X:47374925831780
@f===false,
@t===true,
@g===3.141592653589796,
@n===nil,
@y=31.42
>
},
"c"
]
41 42 43 44 |
# File 'lib/pretty_inspect.rb', line 41 def pretty_inspect(max_level=999) object_ids = [] pretty_inspect_core("", self, 0, "", object_ids, max_level-1) end |