Yet another ruby question but this is a bunch of questions in one. I'm really starting to like rails but there are some questions that I'd just like to ask straight out.
Right now, I'm implementing a queue in sqlite. I already have a scaffold setup with this working OK. The purpose is for a web crawler to read through the array and determine which links he should crawl next.
The architecture in the program is 2 controllers. one for Job and one for crawler. The Jobs has the standard Crud interface supplied by scaffold. Where I'm falling down is I'm still trying to understand how these things communicate with eachother.
The Job is formatted as a url:string and depth:decimal. The table is already populated with about 4 objects.
@sitesToCrawl = Job.all
@sitesToCrawl.each {|x|puts Job.url}
I have a bunch of questions about the above.
At the moment, this was supposed to display all the jobs and I foolishly thought it would display plain text but its actually a hexidecimal pointer to the object itself. What Im trying to do is iterate through the @sitesToCrawl and put out each Jobs url.
Questions start here:
1: I know ruby is dynamically typed. Will @sitesToCrawl become an array like i want it to be with each slot containing a job.
2: @sitesToCrawl.each is pretty straighforward and I'm assuming its an iterator.
is X the name od the method or what is the purpose of the symbol or string between |*|
3: Puts and print are more or less the same yes? if i say @x = puts 3 then would x be 3?
4: Job.url. Can objects be referenced this way or should I be using
#@sitesToCrawl = db.execute("SELECT url FROM jobs;")
where db is a new database
@sitesToCrawl.each {|x|puts x.url}. BasicallyJobis the class andxis the variable in which you captured the objects yielded byeachiterator.