37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/leboncoin/items.rb', line 37
def
require 'rss/maker'
content = RSS::Maker.make("2.0") do |m|
m.channel.title = "leboncoin.fr"
m.channel.link = @link
m.channel.description = "leboncoin.fr"
m.items.do_sort = true
@items.each do |item|
price = ""
if item["price"] != nil
price = item["price"].to_s + " " + item["currency"]
end
postcode = ""
if item["postcode"] != nil
postcode = item["postcode"]
end
i = m.items.new_item
i.title = item["title"]
i.link = item["link"]
begin
i.description = LeBonCoin::HTMLUtils.convert("<img src='" + item["image"] + "'/><br/>" \
+ "<b>Ville</b> : " + item["city"] + "<br/>" \
+ "<b>Code postal</b> : " + postcode + "<br/>" \
+ "<p>" + item["description"] + "</p><hr/>" \
+ "<b>Prix</b> : " + price + "<hr/>")
rescue
require 'json'
puts ">>>> ERROR >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
puts JSON.pretty_generate(item)
puts "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
end
i.date = Time.now end
end
end
|