Git Product home page Git Product logo

Comments (7)

craiglittle avatar craiglittle commented on June 14, 2024

Could you provide specific examples with expected output?

At first glance, I'm not sure if this is something that needs to or should live in the gem itself.

from biz.

pocman avatar pocman commented on June 14, 2024

It might be too specific.
It could be nice if TimeSegment had some kind of interval API :

  • intersection (overlapping).
  • union (it might be tricky for none overlapping segments).
  • contains (an other segment).
    Le 3 avr. 2016 21:13, "Craig Little" [email protected] a écrit :

Could you provide specific examples with expected output?

At first glance, I'm not sure if this is something that needs to or should
live in the gem itself.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#54 (comment)

from biz.

craiglittle avatar craiglittle commented on June 14, 2024

Two out of the three already exist on TimeSegment. The only one that doesn't is the tricky union.

Does that address your use case?

from biz.

pocman avatar pocman commented on June 14, 2024

The contains? seems to take a Time and not a TimeSegment.

2016-04-05 2:39 GMT+02:00 Craig Little [email protected]:

Two out of the three already exist on TimeSegment

def contains?(time)
(start_time..end_time).cover?(time)
end
def &(other)
lower_bound = [self, other].map(&:start_time).max
upper_bound = [self, other].map(&:end_time).min
self.class.new(lower_bound, [lower_bound, upper_bound].max)
end
.
The only one that doesn't is the tricky union.

Does that address your use case?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#54 (comment)

Thomas Pocreau
Recherche & Développement | Colisweb

[email protected]
06 45 12 61 58
Euratechnologies | 165, Avenue de Bretagne
59000 - Lille

from biz.

craiglittle avatar craiglittle commented on June 14, 2024

How about doing something like:

ts1.endpoints.all? { |endpoint| ts2.contains?(endpoint) }

from biz.

pocman avatar pocman commented on June 14, 2024

Yes, I did it this way but contains? is error prone since it returns false
when you pass a TimeSegment.

Thanks a lot for your feedback :-)
Le 5 avr. 2016 09:49, "Craig Little" [email protected] a écrit :

How about doing something like:

ts1.endpoints.all? { |endpoint| ts2.contains?(endpoint) }


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#54 (comment)

from biz.

craiglittle avatar craiglittle commented on June 14, 2024

No problem! Yeah, unfortunately, that's sort of the nature of weakly typed languages like Ruby. Without adding a bunch of type checks everywhere, one must understand what the method expects to receive. At least it didn't return true every time, eh? :)

I'll definitely keep this use case in mind in case I hear similar needs from other users, but I'm going to close the issue for now. Thanks for putting the gem through its paces! Please let me know if you run into anything else.

from biz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.