<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: pp code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 23 Jul 2008 19:11:24 GMT</pubDate>
    <description>DZone Snippets: pp code</description>
    <item>
      <title>Pretty print in Nu</title>
      <link>http://snippets.dzone.com/posts/show/5782</link>
      <description>I miss the 'pp' helper method in Ruby. Fortunately Nu has "-description" method on objects, which is like a #to_pretty_print method in Ruby. So, implementing "pp" takes one line of code:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;(function pp (obj) (puts (obj description)))&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And for a demonstration:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ nush&lt;br /&gt;Nu Shell.&lt;br /&gt;% (function pp (obj) (puts (obj description)))&lt;br /&gt;(do (obj) ((puts (obj description))))&lt;br /&gt;% (pp (array 1 2 3 (array "a" "b" 10)))&lt;br /&gt;(&lt;br /&gt;    1,&lt;br /&gt;    2,&lt;br /&gt;    3,&lt;br /&gt;        (&lt;br /&gt;        a,&lt;br /&gt;        b,&lt;br /&gt;        10&lt;br /&gt;    )&lt;br /&gt;)&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Thanks to Patrick Thomson for this!</description>
      <pubDate>Fri, 18 Jul 2008 00:27:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5782</guid>
      <author>nicwilliams (Dr Nic Williams)</author>
    </item>
    <item>
      <title>Load a Web page in Ruby and print information</title>
      <link>http://snippets.dzone.com/posts/show/2430</link>
      <description>Found at &lt;a href="http://www.juretta.com/log/2006/08/13/ruby_net_http_and_open-uri/"&gt;http://www.juretta.com/log/2006/08/13/ruby_net_http_and_open-uri/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'open-uri'&lt;br /&gt;require 'pp'&lt;br /&gt;&lt;br /&gt;open('http://www.juretta.com/') do |f|&lt;br /&gt;  # hash with meta information&lt;br /&gt;  pp  f.meta&lt;br /&gt;   &lt;br /&gt;  # &lt;br /&gt;  pp "Content-Type: " + f.content_type&lt;br /&gt;  pp "last modified" + f.last_modified.to_s&lt;br /&gt;  &lt;br /&gt;  no = 1&lt;br /&gt;  # print the first three lines&lt;br /&gt;  f.each do |line|&lt;br /&gt;    print "#{no}: #{line}"&lt;br /&gt;    no += 1&lt;br /&gt;    break if no &gt; 4&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 16 Aug 2006 21:36:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2430</guid>
      <author>jswizard (JavaScript Wizard)</author>
    </item>
  </channel>
</rss>
