[Vit-discuss] Top Ruby Projects algorithm?

James Edward Gray II james at grayproductions.net
Fri Aug 25 20:58:37 EDT 2006


On Aug 25, 2006, at 3:59 PM, why the lucky stiff wrote:

> On Fri, Aug 25, 2006 at 03:32:00PM -0400, John W. Long wrote:
>> Suggestions?
>
> Some short list samples would be nice:
>
>>> [14, 37, 25].max
>   => 37
>>> ['www', 'ruby-lang', org'] * '.'
>   => 'www.ruby-lang.org'
>>> ['donkeys', 'trucks', 'spades'].include? 'monkey'
>   => false
>
> Or reading over HTTP:
>
>   # Ruby comes with OpenURI, a library for reading
>   # files over the web easily.  Watch:
>>> require 'open-uri'
>>> open("http://ruby-lang.org/en/license.txt") do |file|
>   ..   puts file.read
>   .. end
>
> Or a little Builder demo:
>
>   # Builder, a library offered for Ruby, lets
>   # you describe RSS in ordinary Ruby!
>>> feed.rss :version => '2.0' do
>   ..   feed.title 'The Ruby Homepage'
>   ..   feed.link  'http://www.ruby-lang.org'
>   ..   feed.item {}
>   .. end

The biggest problem with most ideas people are showing is space.   
It's a very, very small box.  Here's what I had to use to get the  
latest snippet to fit:

   # Ruby knows what you
   # mean, even if you
   # want to do math on
   # an entire Array
   cities  = %w[ London
                 Oslo
                 Paris
                 Amsterdam
                 Berlin ]
   visited = %w[Berlin Oslo]

   puts "I still need " +
        "to visit the " +
        "following cities:",
        cities - visited

That fills the box in every direction.  It's really hard to squeeze  
something like a URL in that space.

For this reason and others, John and I favor the simplicity of the  
hello world snippet, where we still use the comments to get some fun  
information to the user.

James Edward Gray II


More information about the vit-discuss mailing list