First Dino Dex Program

I have it set up right now to just run the code in the Main class, and it prints the results to the console.
Looking at this again, I'm not sure I should refactor it.  When you wrote
this, I'm not sure you had seen how exactly I am doing the { operator => {
attribute: value } } usage.  Both the options and the filters go together
and I think it is a little confusing to pull it apart (I would have to pass
like 5 params to the method).  What do you think?

*Jeremy Finzel*

*Senior Database Developer*
*M* 630-777-4520




On Tue, Dec 16, 2014 at 8:26 PM, Joseph Mastey <notifications@github.com>
wrote:
>
> In dino_catalog/dinosaur_info.rb
> <https://github.com/jmmastey/level_up_exercises/pull/350#discussion-diff-21949074>
> :
>
> > +
> > +  # options should be in the following format
> > +  # { operator <string> => { attribute: value } }
> > +  def filter_dinosaurs(options = {})
> > +    @dinosaurs_filtered = @dinosaurs
> > +    @filters = options
> > +    options.each do |operator, filters|
> > +      filters.each do |key, value|
> > +        @dinosaurs_filtered =
> > +            @dinosaurs_filtered.select do |dinosaur|
> > +              dinosaur.send("#{key}").send(operator, value)
> > +            end
> > +      end
> > +    end
> > +    @dinosaurs_filtered
> > +  end
>
> This is too complicated as a method. Refactor into some smaller methods.
> Also, this is still too many instance vars. Send some params.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/jmmastey/level_up_exercises/pull/350/files#r21949074>.
>