R
Robin Wagenaar
Hello everyone,
My level of ruby-experience has just slightly passed hello-world, I'm
quite new to this programming language; I hope I don't bother all of you
too much by posting my low-level question here.
I would like to make a program that iterates recursively trough my music
directory, and selects the top-10 of most recently played tracks.
I try to use File.atime(path) to check if the current file is accessed
recently enough to get into my top-10, but my problem is that I don't
know how to (correctly) compare a date to the return value of
File.atime.
I'm sure you can give me some simple hints, or a small push in the right
direction. Thanks in advance.
this is what I have so far:
require 'find'
require 'date'
dir = "/share/music"
Find.find(dir) do |path|
if File.directory?(path)
next
else
if path.match(".*mp3") != nil
print File.atime(path)," : "
print path,"\n"
end
end
end
My level of ruby-experience has just slightly passed hello-world, I'm
quite new to this programming language; I hope I don't bother all of you
too much by posting my low-level question here.
I would like to make a program that iterates recursively trough my music
directory, and selects the top-10 of most recently played tracks.
I try to use File.atime(path) to check if the current file is accessed
recently enough to get into my top-10, but my problem is that I don't
know how to (correctly) compare a date to the return value of
File.atime.
I'm sure you can give me some simple hints, or a small push in the right
direction. Thanks in advance.
this is what I have so far:
require 'find'
require 'date'
dir = "/share/music"
Find.find(dir) do |path|
if File.directory?(path)
next
else
if path.match(".*mp3") != nil
print File.atime(path)," : "
print path,"\n"
end
end
end