Skip to content
Browse files

refactor Scissor::Fragment#create

  • Loading branch information...
1 parent b67a298 commit 92877caa9f170be657df27fcf03777ac55369c00 @youpy committed
Showing with 18 additions and 26 deletions.
  1. +18 −26 lib/scissor/fragment.rb
View
44 lib/scissor/fragment.rb
@@ -32,37 +32,29 @@ def stretched?
end
def create(remaining_start, remaining_length)
- new_fragment = nil
-
if remaining_start >= duration
- remaining_start -= duration
- else
- if remaining_start + remaining_length >= duration
- new_fragment = self.class.new(
- filename,
- start + remaining_start * pitch.to_f / 100,
- (duration - remaining_start) * pitch.to_f / 100,
- false,
- pitch,
- stretched?)
+ return [nil, remaining_start - duration, remaining_length]
+ end
- remaining_length -= duration - remaining_start
- remaining_start = 0
- else
- new_fragment = self.class.new(
- filename,
- start + remaining_start * pitch.to_f / 100,
- remaining_length * pitch.to_f / 100,
- false,
- pitch,
- stretched?)
+ have_remain_to_return = (remaining_start + remaining_length) >= duration
- remaining_start = 0
- remaining_length = 0
- end
+ if have_remain_to_return
+ new_length = duration - remaining_start
+ remaining_length -= new_length
+ else
+ new_length = remaining_length
+ remaining_length = 0
end
- return new_fragment, remaining_start, remaining_length
+ new_fragment = self.class.new(
+ filename,
+ start + remaining_start * pitch.to_f / 100,
+ new_length * pitch.to_f / 100,
+ false,
+ pitch,
+ stretched?)
+
+ return [new_fragment, 0, remaining_length]
end
end
end

0 comments on commit 92877ca

Please sign in to comment.
Something went wrong with that request. Please try again.