Skip to content

Conversation

@meltar
Copy link

@meltar meltar commented Mar 11, 2013

I finished panda, tiger, and eagle.

movie_json.rb Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A cool thing in ruby --- you can tell movies what attribute you want it to collect. (collect is an alias for map, so I'm going to use map below)

data = movies.map(&:attribute)
data.inject(0.0) { |sum, rating| sum + rating } / data.size

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there would likely be a cool Ruby thing that would do this in a generic way, but I'm unfamiliar with the &:attribute notation, so I couldn't get it to work. I need to spend some time going through the Enumerable module.

@jwo
Copy link
Member

jwo commented Mar 12, 2013

Looks really good! My only suggestion is that when you are rescue'ing the find_movie method, you could be rescuing too many exceptions. I'd rather the API that does the search know that there is a condition where a movie can be not-found, and return that condition.

The downside to a blank "rescue" is that it hides all exceptions that might occur, such as the website being down, or problems with your code.

@meltar
Copy link
Author

meltar commented Mar 12, 2013

That makes sense. I had to comment out the rescue sometimes in order to figure out why the program wasn't working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants