AAHH!! Got it :)


On Wed, Mar 19, 2014 at 3:10 PM, Gilbert <notifications@github.com> wrote:

> In lib/task-manager/project.rb:
>
> > +    # add the task to the @tasks hash
> > +    @tasks[task_object.task_id] = task_object
> > +  end
> > +
> > +  def mark_as_finished(task_id)
> > +    @tasks[task_id].finished = true
> > +  end
> > +
> > +  def completed_tasks  #returns completed_tasks in the proper order
> > +    completed_tasks = @tasks.select { |k,v| v.finished? == true }.values
> > +    return completed_tasks.sort { |a,b| a.creation_date <=> b.creation_date }
> > +  end
> > +
> > +  def ongoing_tasks  #returns ongoing_tasks in the proper order
> > +    ongoing_tasks = @tasks.select { |k,v| v.finished? == false }.values
> > +    ongoing_tasks.sort! { |a,b| (a.priority <=> b.priority) == 0 ? (a.creation_date <=> b.creation_date) : (b.priority <=> a.priority) }
>
> You can simplify this by checking for equality:
>
> ongoing_tasks.sort! { |a,b| (a.priority == b.priority) ? (a.creation_date
> <=> b.creation_date) : (b.priority <=> a.priority) }
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/makersquare/ruby-course/pull/101/files#r10769010>
> .
>



-- 
www.briankeane.net
www.myspace.com/briankeane