This is a topic in Basecamp API

Weird code in the ruby wrapper

 
Avatar Matt Grande 12 posts

I was looking at the ruby wrapper for the api, and I came across this line of code:

if response.code.to_i / 100 2

Why would you do this? Is there an advantage to comparing response.code ‘200’ (which they do a few lines down for 302s)?

 
Avatar Matt Grande 12 posts

Over 700 readers and no reply? So I guess there’s no good explaination for this?

 
Avatar Jeff Hardy Staff 262 posts

Hi Matt—

It’s so response codes anywhere within the 200-299 range will be interpreted as success:

$ irb
>> 201 / 100 == 2
=> true
 
Avatar Matt Grande 12 posts

Ahh, I see! Thanks Jeff!

Signup or login to post a reply.