From: dblack@... Date: 2006-11-08T10:54:43+09:00 Subject: Re: can you rubyfy this? Hi -- On Wed, 8 Nov 2006, Boris Schulz wrote: > Hi, > > I often read something about code being "rubystyle" though I am not exactly > sure what it means. Maybe someone can help me out and put the couple of > lines below into a typical ruby style? > > greets, B. > - - - - - - - - - - - > #!/usr/bin/ruby > require "rexml/document"; Lose the semi-colons :-) > require "id3lib"; > include REXML; > include ID3Lib; > > doc = Document.new File.new("collection.nml") > > entrys = doc.elements.to_a("//ENTRY") > entrys.each{|node| > file = node.elements["LOCATION"].attributes["DIR"] + Indentation is normally/traditionally two spaces. You can get a good sense of traditional style from (most of :-) the code in the standard library. David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org