Re: Parsing data: Part 2

Yes. My friend said that the best way to go about doing this would probably be from using DateTime. I haven't used that before, but would you agree? Or do you have a different method in mind?

My regex is pretty bad, but I can cheat a little bit using the one he provided until I'm able to get the hang of that more. I don't plan on using any of his other code suggestions, though, as that would defeat the purpose of what I'm trying to do here (though it will be a good reference for afterward to see how I could have done it).

I'm stuck at trying to figure out how I would get this portion of it started. I can do the math manually, but I can't think of how I'd tell the computer to do the math. Would you possibly be able to get me started with how it would start out so I can try and see if I can figure out the rest?

That will return a hash, but each hash element contains an ARRAY (except for :command), the first element in the array is the original cron definition, the second element is an integer.

Now you only have to figure out the math logic, see if you can figure out from this:

file = File.new("file.log", "r")
while (line = file.gets)
parts = parse_cron(line)
puts "The cron command is #{parts[:command]}"
puts "The minutes definition looks like #{parts[:min][0]} and has a value of #{parts[:min][1]}"
end

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Are you sure that that is the ONLY file with a .log extension in the directory where you are running the program?

Hmm, I think I probably just messed it up while I was trying to fix it I did a fresh copy/paste and it worked. Still give the other error when doing the other files, so I'll have to do them one-by-one. I won't have time to do that tonight, but I'll let you know as soon as I do!

Re: Parsing data: Part 2

Like I said, my test cases were minimal. I'll add some exception handling, then you won't have to do the tedious job of isolating the specific file that makes it barf. I'll make it so you can run it against lots of files, and it will tell YOU which file it barfed on.

Stay tuned

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Parsing data: Part 2

My grasp of Ruby isn't that great, it's just another language. It's a grasp of programming that is important. I've programmed in so many languages over the years, they all kind of blur in my mind. Starting with an HP-25C calculator programming RPN in 1975, I've programmed in the following additional languages

It's the API's that are the real killer, Rails took longer to master than Ruby.J2EE took longer to master than Java, (hell, having programmed in C++ and Ada, Java's learning curve was about 2 days, J2EE was unbearably long, never did stick with it, I thought it was a bloated piece of crap!

Ruby on Rails is by far the best programming environment I've ever used, no contest!

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.