Skip to content

Instantly share code, notes, and snippets.

@andreyvit
Created May 31, 2009 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreyvit/121003 to your computer and use it in GitHub Desktop.
Save andreyvit/121003 to your computer and use it in GitHub Desktop.
# min(alchogol to understand this func), vodka, cognac or “Gay Milker” kefir only
def apply_deletion range
return self if range.start >= self.end # -500 ml
len_diff = [self.length, range.length, self.end - range.start, range.end - self.start].min # 1000 ml
new_start = [range.start - [0, len_diff].min, self.start].min # 300 ml
TimeRange.new(new_start, new_start + self.length - [0, len_diff].max) # 700 ml
# total: 1500 ml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment