Intrepidd / working_hours

⏰ A modern ruby gem allowing to do time calculation with business / working hours.
https://github.com/Intrepidd/working_hours
MIT License
533 stars 30 forks source link

Core Time classes monkey patches #2

Closed Intrepidd closed 10 years ago

Intrepidd commented 10 years ago

This PR is not ready yet, it's done to implement syntax described in issue #1

I've implemented + and - for now using some metaprogramming but I'm not sure it's worth it doing it this way

Probably manually implementing + and - would be a better idea ? WDYT ?

def +_with_working_hours(other)
  if (other.is_a?(WorkingHours::Duration)
    other + self
  else
    self.+_without_working_hours(other)
  end
end

def -_with_working_hours(other)
  if (other.is_a?(WorkingHours::Duration)
    other - self
  else
    self.-_without_working_hours(other)
  end
end
jarthod commented 10 years ago

Indeed I would prefer the more explicit way :)

jarthod commented 10 years ago

Any update ?

Intrepidd commented 10 years ago

As we said the method name is invalid, we agreed to drop 1.9 support and use prepend, the future is now!

I'll update this today On Aug 15, 2014 11:28 AM, "Adrien Jarthon" notifications@github.com wrote:

Any update ?

— Reply to this email directly or view it on GitHub https://github.com/Intrepidd/working_hours/pull/2#issuecomment-52289059.

jarthod commented 10 years ago

\o/

Intrepidd commented 10 years ago

There we go, let's see if travis is happy

Intrepidd commented 10 years ago

I also rebased the branch on master :)

jarthod commented 10 years ago

Ok thanks, I'll probably merge these small files