B
Boris Schulz
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";
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"] +
node.elements["LOCATION"].attributes["FILE"]
if File.exists?(file)
tag = Tag.new(file)
if !node.attributes["ARTIST"]
node.add_element "ARTIST"
end
node.attributes["ARTIST"] = tag.artist
end
}
out = File.new("test.xml", "w+")
doc.write out
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";
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"] +
node.elements["LOCATION"].attributes["FILE"]
if File.exists?(file)
tag = Tag.new(file)
if !node.attributes["ARTIST"]
node.add_element "ARTIST"
end
node.attributes["ARTIST"] = tag.artist
end
}
out = File.new("test.xml", "w+")
doc.write out