| 20 | | posts.each { |
|---|
| 21 | | |post| |
|---|
| 22 | | puts post.attributes["description"] |
|---|
| 23 | | puts " " + post.attributes["href"] |
|---|
| 24 | | puts " " + post.attributes["tag"].gsub( / /, ", " ) + "\n\n" |
|---|
| 25 | | } |
|---|
| | 22 | def who_else_saved( url ) |
|---|
| | 23 | "http://del.icio.us/url/" + Digest::MD5.hexdigest( url ) |
|---|
| | 24 | end |
|---|
| | 25 | |
|---|
| | 26 | def dump_link( link ) |
|---|
| | 27 | puts link.attributes["description"] |
|---|
| | 28 | puts " " + link.attributes["href"] |
|---|
| | 29 | puts " " + link.attributes["tag"].gsub( / /, ", " ) |
|---|
| | 30 | puts " " + who_else_saved( link.attributes["href"] ) |
|---|
| | 31 | puts "\n" |
|---|
| | 32 | end |
|---|
| | 33 | |
|---|
| | 34 | def dump_links |
|---|
| | 35 | links.each { |link| dump_link link } |
|---|
| | 36 | end |
|---|
| | 37 | |
|---|
| | 38 | def dump_random_links( links, n ) |
|---|
| | 39 | puts "here are " + n.to_s + ", chosen at random:" |
|---|
| | 40 | puts "======================================" |
|---|
| | 41 | for i in (1.. n) |
|---|
| | 42 | dump_link( links[ rand(links.length) ] ) |
|---|
| | 43 | end |
|---|
| | 44 | end |
|---|
| | 45 | |
|---|
| | 46 | def dump_most_recent( links, n ) |
|---|
| | 47 | puts "here are the " + n.to_s + " most recent:" |
|---|
| | 48 | puts "======================================" |
|---|
| | 49 | for i in (0 .. n-1) |
|---|
| | 50 | dump_link( links[i] ) |
|---|
| | 51 | end |
|---|
| | 52 | end |
|---|
| | 53 | |
|---|
| | 54 | dump_random_links( links, NUM_LINKS_FOR_ALL_TAGS) |
|---|
| | 55 | dump_most_recent( links, NUM_LINKS_FOR_ALL_TAGS) |
|---|
| | 56 | |
|---|
| | 57 | exit |
|---|
| | 58 | |
|---|