julik-timecode 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +1 -2
- data/README.txt +1 -1
- data/SPECS.txt +7 -1
- data/lib/timecode.rb +7 -7
- data/test/test_timecode.rb +26 -0
- data/timecode.gemspec +1 -1
- metadata +1 -1
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
data/SPECS.txt
CHANGED
@@ -51,8 +51,14 @@
|
|
51
51
|
* disallow more frames than what the framerate permits
|
52
52
|
* propery accept usable values
|
53
53
|
|
54
|
+
== A custom Timecode descendant should
|
55
|
+
* properly classify on parse
|
56
|
+
* properly classify on at
|
57
|
+
* properly classify on calculations
|
58
|
+
|
54
59
|
== Timecode.parse() should
|
55
60
|
* handle complete SMPTE timecode
|
61
|
+
* handle complete SMPTE timecode via new
|
56
62
|
* refuse to handle timecode that is out of range for the framerate
|
57
63
|
* parse a row of numbers as parts of a timecode starting from the right
|
58
64
|
* parse a number with f suffix as frames
|
@@ -71,4 +77,4 @@
|
|
71
77
|
* parse from a 4x4bits packed 32bit unsigned int
|
72
78
|
* properly convert itself back to 4x4 bits 32bit unsigned int
|
73
79
|
|
74
|
-
|
80
|
+
52 specifications (87 requirements), 0 failures
|
data/lib/timecode.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# :mapping => [%w(source_tc_frames total), %w(tape_fps fps)]
|
13
13
|
|
14
14
|
class Timecode
|
15
|
-
VERSION = '0.1.
|
15
|
+
VERSION = '0.1.6'
|
16
16
|
|
17
17
|
include Comparable
|
18
18
|
|
@@ -252,29 +252,29 @@ class Timecode
|
|
252
252
|
# add number of frames (or another timecode) to this one
|
253
253
|
def +(arg)
|
254
254
|
if (arg.is_a?(Timecode) && framerate_in_delta(arg.fps, @fps))
|
255
|
-
|
255
|
+
self.class.new(@total+arg.total, @fps)
|
256
256
|
elsif (arg.is_a?(Timecode))
|
257
257
|
raise WrongFramerate, "You are calculating timecodes with different framerates"
|
258
258
|
else
|
259
|
-
|
259
|
+
self.class.new(@total + arg, @fps)
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
263
263
|
# Subtract a number of frames
|
264
264
|
def -(arg)
|
265
265
|
if (arg.is_a?(Timecode) && framerate_in_delta(arg.fps, @fps))
|
266
|
-
|
266
|
+
self.class.new(@total-arg.total, @fps)
|
267
267
|
elsif (arg.is_a?(Timecode))
|
268
268
|
raise WrongFramerate, "You are calculating timecodes with different framerates"
|
269
269
|
else
|
270
|
-
|
270
|
+
self.class.new(@total-arg, @fps)
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
274
|
# Multiply the timecode by a number
|
275
275
|
def *(arg)
|
276
276
|
raise RangeError, "Timecode multiplier cannot be negative" if (arg < 0)
|
277
|
-
|
277
|
+
self.class.new(@total*arg.to_i, @fps)
|
278
278
|
end
|
279
279
|
|
280
280
|
# Get the next frame
|
@@ -285,7 +285,7 @@ class Timecode
|
|
285
285
|
# Get the number of times a passed timecode fits into this time span (if performed with Timecode) or
|
286
286
|
# a Timecode that multiplied by arg will give this one
|
287
287
|
def /(arg)
|
288
|
-
arg.is_a?(Timecode) ? (@total / arg.total) :
|
288
|
+
arg.is_a?(Timecode) ? (@total / arg.total) : self.class.new(@total /arg, @fps)
|
289
289
|
end
|
290
290
|
|
291
291
|
# Timecodes can be compared to each other
|
data/test/test_timecode.rb
CHANGED
@@ -219,6 +219,32 @@ context "Timecode.at() should" do
|
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
222
|
+
context "A custom Timecode descendant should" do
|
223
|
+
class CustomTC < Timecode; end
|
224
|
+
|
225
|
+
specify "properly classify on parse" do
|
226
|
+
CustomTC.parse("001").should.be.kind_of CustomTC
|
227
|
+
end
|
228
|
+
|
229
|
+
specify "properly classify on at" do
|
230
|
+
CustomTC.at(10,10,10,10).should.be.kind_of CustomTC
|
231
|
+
end
|
232
|
+
|
233
|
+
specify "properly classify on calculations" do
|
234
|
+
computed = CustomTC.parse("10h") + Timecode.new(10)
|
235
|
+
computed.should.be.kind_of CustomTC
|
236
|
+
|
237
|
+
computed = CustomTC.parse("10h") - Timecode.new(10)
|
238
|
+
computed.should.be.kind_of CustomTC
|
239
|
+
|
240
|
+
computed = CustomTC.parse("10h") * 5
|
241
|
+
computed.should.be.kind_of CustomTC
|
242
|
+
|
243
|
+
computed = CustomTC.parse("10h") / 5
|
244
|
+
computed.should.be.kind_of CustomTC
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
222
248
|
|
223
249
|
context "Timecode.parse() should" do
|
224
250
|
|
data/timecode.gemspec
CHANGED