How to view the structure of a hash

I keep finding myself trying to decipher the structure of hash objects
and when I just print the hash, I get pages of scrolling text because
it's showing all elements and text in the hash, and that is of very
little help. Can someone tell me some ways of better viewing the
structure of my hash objects?

Syntax from memory, so please forgive errors...

$hash.each{|k,v|
   puts v
}

You'll want to do a bit more to make it readable, but this gives you
control on a per-object level...

HTH,
Carey

···

-----Original Message-----
From: eggman2001 [mailto:sodani@gmail.com]
Sent: Thursday, December 08, 2011 7:21 PM
To: ruby-talk ML
Subject: how to view the structure of a hash

I keep finding myself trying to decipher the structure of hash objects
and when I just print the hash, I get pages of scrolling text because
it's showing all elements and text in the hash, and that is of very
little help. Can someone tell me some ways of better viewing the
structure of my hash objects?

Would awesome_print( GitHub - michaeldv/awesome_print ) work?
-Nick Klauer

···

On Thu, Dec 8, 2011 at 18:21, eggman2001 <sodani@gmail.com> wrote:

I keep finding myself trying to decipher the structure of hash objects
and when I just print the hash, I get pages of scrolling text because
it's showing all elements and text in the hash, and that is of very
little help. Can someone tell me some ways of better viewing the
structure of my hash objects?

eggman2001 писал 09.12.2011 04:21:

I keep finding myself trying to decipher the structure of hash objects
and when I just print the hash, I get pages of scrolling text because
it's showing all elements and text in the hash, and that is of very
little help. Can someone tell me some ways of better viewing the
structure of my hash objects?

require 'pp' # Pretty printer
pp hash

···

--
   WBR, Peter Zotov.

Peter Zotov already suggested the way to go.

Via pp. pretty print.

  require 'pp'
  pp hash

This doesn't really change much in my opinion because
the values are so big.

If your hash is really huge, I would randomly select only a subset of
these and pretty print them.

And also use Wirble if you do this in IRB, it really is colouring
nicely.

···

--
Posted via http://www.ruby-forum.com/\.

This doesn't really change much in my opinion because the values are
so big.

···

On Dec 8, 7:54 pm, "Nation, Carey" <Carey.Nat...@turner.com> wrote:

Syntax from memory, so please forgive errors...

$hash.each{|k,v|
puts v

}

You'll want to do a bit more to make it readable, but this gives you
control on a per-object level...

HTH,
Carey

-----Original Message-----
From: eggman2001 [mailto:sod...@gmail.com]
Sent: Thursday, December 08, 2011 7:21 PM
To: ruby-talk ML
Subject: how to view the structure of a hash

I keep finding myself trying to decipher the structure of hash objects
and when I just print the hash, I get pages of scrolling text because
it's showing all elements and text in the hash, and that is of very
little help. Can someone tell me some ways of better viewing the
structure of my hash objects?

Thank you all for the responses. I'll try these all out.

···

On Dec 9, 10:10 am, Marc Heiler <sheve...@linuxmail.org> wrote:

Peter Zotov already suggested the way to go.

Via pp. pretty print.

require 'pp'
pp hash

> This doesn't really change much in my opinion because
> the values are so big.

If your hash is really huge, I would randomly select only a subset of
these and pretty print them.

And also use Wirble if you do this in IRB, it really is colouring
nicely.

--
Posted viahttp://www.ruby-forum.com/.

What exactly do you want to discover about the hash? What it's values
are? It's size? Number of elements?

···

On 12/08/2011 09:14 PM, eggman2001 wrote:

This doesn't really change much in my opinion because the values
are so big.

On Dec 8, 7:54 pm, "Nation, Carey" <Carey.Nat...@turner.com> > wrote:

Syntax from memory, so please forgive errors...

$hash.each{|k,v| puts v

}

You'll want to do a bit more to make it readable, but this gives
you control on a per-object level...

HTH, Carey

-----Original Message----- From: eggman2001
[mailto:sod...@gmail.com] Sent: Thursday, December 08, 2011 7:21
PM To: ruby-talk ML Subject: how to view the structure of a hash

I keep finding myself trying to decipher the structure of hash
objects and when I just print the hash, I get pages of scrolling
text because it's showing all elements and text in the hash, and
that is of very little help. Can someone tell me some ways of
better viewing the structure of my hash objects?

- --
frosty
public key: unluckyfrosty.net/public_key

Notice the "you'll want to do a bit more to make it readable" part.

···

-----Original Message-----
From: eggman2001 [mailto:sodani@gmail.com]
Sent: Thursday, December 08, 2011 10:14 PM
To: ruby-talk ML
Subject: Re: how to view the structure of a hash

This doesn't really change much in my opinion because the values are so big.

On Dec 8, 7:54 pm, "Nation, Carey" <Carey.Nat...@turner.com> wrote:

Syntax from memory, so please forgive errors...

$hash.each{|k,v|
puts v

}

You'll want to do a bit more to make it readable, but this gives you
control on a per-object level...

HTH,
Carey

-----Original Message-----
From: eggman2001 [mailto:sod...@gmail.com]
Sent: Thursday, December 08, 2011 7:21 PM
To: ruby-talk ML
Subject: how to view the structure of a hash

I keep finding myself trying to decipher the structure of hash objects
and when I just print the hash, I get pages of scrolling text because
it's showing all elements and text in the hash, and that is of very
little help. Can someone tell me some ways of better viewing the
structure of my hash objects?