VRFS-4113 - lesson analysis error dealt with
This commit is contained in:
parent
2dafc8288a
commit
021dc47d89
|
|
@ -285,7 +285,8 @@ module JamRuby
|
|||
}
|
||||
end
|
||||
|
||||
def self.intersect(a, b)
|
||||
# not OK for time objects. Here for docs more than anything
|
||||
def self.intersect2(a, b)
|
||||
min, max = a.first, a.exclude_end? ? a.max : a.last
|
||||
other_min, other_max = b.first, b.exclude_end? ? b.max : b.last
|
||||
|
||||
|
|
@ -295,6 +296,23 @@ module JamRuby
|
|||
new_min && new_max ? Range.new(new_min, new_max) : nil
|
||||
end
|
||||
|
||||
|
||||
def self.contained_by(a, test)
|
||||
min, max = a.first, a.exclude_end? ? a.max : a.last
|
||||
|
||||
test >= min && test <= max
|
||||
end
|
||||
|
||||
def self.intersect(a, b)
|
||||
min, max = a.first, a.exclude_end? ? a.max : a.last
|
||||
other_min, other_max = b.first, b.exclude_end? ? b.max : b.last
|
||||
|
||||
new_min = contained_by(a, other_min) ? other_min : contained_by(b, min) ? min : nil
|
||||
new_max = contained_by(a, other_max) ? other_max : contained_by(b, max) ? max : nil
|
||||
|
||||
new_min && new_max ? Range.new(new_min, new_max) : nil
|
||||
end
|
||||
|
||||
def self.time_ranges(histories)
|
||||
ranges = []
|
||||
histories.each do |history|
|
||||
|
|
|
|||
Loading…
Reference in New Issue