lib/xkcd.rb in xkcd-1.0.0 vs lib/xkcd.rb in xkcd-1.0.1
- old
+ new
@@ -30,10 +30,10 @@
"#{img_title} : #{img_url}"
end
=end
def self.img
max = JSON.parse(open('http://xkcd.com/info.0.json').read)["num"]
- comic_num = Random.rand(max)
+ comic_num = 1 + rand(max-1)
comic_num = 1 if comic_num == 404 # Avoid 404th comic ;)
comic = JSON.parse(open("http://xkcd.com/#{comic_num}/info.0.json").read)
"#{comic['alt']} : #{comic['img']}"
end
end