codeforamerica/CutePets — pull request #8 by substars (2014-09-26 12:47:34+00:00)
Title: don’t break when Petfinder API returns an array of options or breeds

The Petfinder API returns `option` and `breed` as arrays when there is more than one. This causes `rake tweet_pet` to error every few requests:

```bash
# works
rake tweet_pet
{"option"=>{"$t"=>"hasShots"}}

# doesn't work
rake tweet_pet
{"option"=>[{"$t"=>"hasShots"}, {"$t"=>"noClaws"}, {"$t"=>"altered"}, {"$t"=>"housetrained"}]}
rake aborted!
TypeError: no implicit conversion of String into Integer
/Users/bortega/projects/github/CutePets/lib/cute_pets/pet_fetcher.rb:85:in `[]'
/Users/bortega/projects/github/CutePets/lib/cute_pets/pet_fetcher.rb:85:in `get_petfinder_option'
/Users/bortega/projects/github/CutePets/lib/cute_pets/pet_fetcher.rb:30:in `get_petfinder_pet'
/Users/bortega/projects/github/CutePets/lib/cute_pets.rb:12:in `post_pet'
/Users/bortega/projects/github/CutePets/Rakefile:10:in `block in '
Tasks: TOP => tweet_pet
(See full trace by running task with --trace)
```

This PR handles those cases and formats multiple options in a more readable way.