time_span 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/doc/TimeSpan.html +2 -2
- data/doc/TimeSpan/RelativeTime.html +178 -34
- data/doc/TimeSpan/TimeLine.html +289 -106
- data/doc/TimeSpan/TimeSpan.html +241 -144
- data/doc/_index.html +1 -1
- data/doc/file.README.html +3 -1
- data/doc/index.html +3 -1
- data/doc/method_list.html +68 -28
- data/doc/top-level-namespace.html +1 -1
- data/lib/time_span.rb +49 -22
- data/lib/time_span/version.rb +1 -1
- data/spec/time_span/time_span_spec.rb +36 -1
- data/time_span.gemspec +1 -1
- metadata +5 -5
data/doc/_index.html
CHANGED
@@ -126,7 +126,7 @@
|
|
126
126
|
</div>
|
127
127
|
|
128
128
|
<div id="footer">
|
129
|
-
Generated on
|
129
|
+
Generated on Mon Mar 5 16:04:11 2012 by
|
130
130
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
131
131
|
0.7.5 (ruby-1.9.3).
|
132
132
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -73,10 +73,12 @@
|
|
73
73
|
<p><em>TimeSpan</em>s are automatically attached to a TimeLine, but <em>RelativeTime</em>s are not.</p>
|
74
74
|
|
75
75
|
<p><em>TimeLine</em>s are the only structure with even a moderate data complexity. There is is a hash which keeps the relative position for each RelativeTime. This structure allows more than one RelativeTime to be equal compared to other RelativeTimes.</p>
|
76
|
+
|
77
|
+
<p>For now, clone is disallowed, it could create an object not obeying the rules, such as a RelativeTime pointing to TimeLine not its own.</p>
|
76
78
|
</div></div>
|
77
79
|
|
78
80
|
<div id="footer">
|
79
|
-
Generated on
|
81
|
+
Generated on Mon Mar 5 16:04:11 2012 by
|
80
82
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
81
83
|
0.7.5 (ruby-1.9.3).
|
82
84
|
</div>
|
data/doc/index.html
CHANGED
@@ -73,10 +73,12 @@
|
|
73
73
|
<p><em>TimeSpan</em>s are automatically attached to a TimeLine, but <em>RelativeTime</em>s are not.</p>
|
74
74
|
|
75
75
|
<p><em>TimeLine</em>s are the only structure with even a moderate data complexity. There is is a hash which keeps the relative position for each RelativeTime. This structure allows more than one RelativeTime to be equal compared to other RelativeTimes.</p>
|
76
|
+
|
77
|
+
<p>For now, clone is disallowed, it could create an object not obeying the rules, such as a RelativeTime pointing to TimeLine not its own.</p>
|
76
78
|
</div></div>
|
77
79
|
|
78
80
|
<div id="footer">
|
79
|
-
Generated on
|
81
|
+
Generated on Mon Mar 5 16:04:11 2012 by
|
80
82
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
81
83
|
0.7.5 (ruby-1.9.3).
|
82
84
|
</div>
|
data/doc/method_list.html
CHANGED
@@ -65,6 +65,14 @@
|
|
65
65
|
|
66
66
|
|
67
67
|
<li class="r2 ">
|
68
|
+
<span class='object_link'><a href="TimeSpan/TimeLine.html#%3D%3D-instance_method" title="TimeSpan::TimeLine#== (method)">#==</a></span>
|
69
|
+
|
70
|
+
<small>TimeSpan::TimeLine</small>
|
71
|
+
|
72
|
+
</li>
|
73
|
+
|
74
|
+
|
75
|
+
<li class="r1 ">
|
68
76
|
<span class='object_link'><a href="TimeSpan/TimeSpan.html#%3E-instance_method" title="TimeSpan::TimeSpan#> (method)">#></a></span>
|
69
77
|
|
70
78
|
<small>TimeSpan::TimeSpan</small>
|
@@ -72,7 +80,7 @@
|
|
72
80
|
</li>
|
73
81
|
|
74
82
|
|
75
|
-
<li class="
|
83
|
+
<li class="r2 ">
|
76
84
|
<span class='object_link'><a href="TimeSpan/TimeLine.html#all_endpoint_statuses-instance_method" title="TimeSpan::TimeLine#all_endpoint_statuses (method)">#all_endpoint_statuses</a></span>
|
77
85
|
|
78
86
|
<small>TimeSpan::TimeLine</small>
|
@@ -80,7 +88,7 @@
|
|
80
88
|
</li>
|
81
89
|
|
82
90
|
|
83
|
-
<li class="
|
91
|
+
<li class="r1 ">
|
84
92
|
<span class='object_link'><a href="TimeSpan/TimeLine.html#all_relative_time_statuses-instance_method" title="TimeSpan::TimeLine#all_relative_time_statuses (method)">#all_relative_time_statuses</a></span>
|
85
93
|
|
86
94
|
<small>TimeSpan::TimeLine</small>
|
@@ -88,7 +96,7 @@
|
|
88
96
|
</li>
|
89
97
|
|
90
98
|
|
91
|
-
<li class="
|
99
|
+
<li class="r2 ">
|
92
100
|
<span class='object_link'><a href="TimeSpan/TimeLine.html#append-instance_method" title="TimeSpan::TimeLine#append (method)">#append</a></span>
|
93
101
|
|
94
102
|
<small>TimeSpan::TimeLine</small>
|
@@ -96,7 +104,7 @@
|
|
96
104
|
</li>
|
97
105
|
|
98
106
|
|
99
|
-
<li class="
|
107
|
+
<li class="r1 ">
|
100
108
|
<span class='object_link'><a href="TimeSpan/TimeLine.html#append_to_next-instance_method" title="TimeSpan::TimeLine#append_to_next (method)">#append_to_next</a></span>
|
101
109
|
|
102
110
|
<small>TimeSpan::TimeLine</small>
|
@@ -104,6 +112,30 @@
|
|
104
112
|
</li>
|
105
113
|
|
106
114
|
|
115
|
+
<li class="r2 ">
|
116
|
+
<span class='object_link'><a href="TimeSpan/TimeLine.html#clone-instance_method" title="TimeSpan::TimeLine#clone (method)">#clone</a></span>
|
117
|
+
|
118
|
+
<small>TimeSpan::TimeLine</small>
|
119
|
+
|
120
|
+
</li>
|
121
|
+
|
122
|
+
|
123
|
+
<li class="r1 ">
|
124
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#clone-instance_method" title="TimeSpan::TimeSpan#clone (method)">#clone</a></span>
|
125
|
+
|
126
|
+
<small>TimeSpan::TimeSpan</small>
|
127
|
+
|
128
|
+
</li>
|
129
|
+
|
130
|
+
|
131
|
+
<li class="r2 ">
|
132
|
+
<span class='object_link'><a href="TimeSpan/RelativeTime.html#clone-instance_method" title="TimeSpan::RelativeTime#clone (method)">#clone</a></span>
|
133
|
+
|
134
|
+
<small>TimeSpan::RelativeTime</small>
|
135
|
+
|
136
|
+
</li>
|
137
|
+
|
138
|
+
|
107
139
|
<li class="r1 ">
|
108
140
|
<span class='object_link'><a href="TimeSpan/RelativeTime.html#colinear_with%3F-instance_method" title="TimeSpan::RelativeTime#colinear_with? (method)">#colinear_with?</a></span>
|
109
141
|
|
@@ -249,17 +281,17 @@
|
|
249
281
|
|
250
282
|
|
251
283
|
<li class="r1 ">
|
252
|
-
<span class='object_link'><a href="TimeSpan/
|
284
|
+
<span class='object_link'><a href="TimeSpan/TimeLine.html#initialize-instance_method" title="TimeSpan::TimeLine#initialize (method)">#initialize</a></span>
|
253
285
|
|
254
|
-
<small>TimeSpan::
|
286
|
+
<small>TimeSpan::TimeLine</small>
|
255
287
|
|
256
288
|
</li>
|
257
289
|
|
258
290
|
|
259
291
|
<li class="r2 ">
|
260
|
-
<span class='object_link'><a href="TimeSpan/
|
292
|
+
<span class='object_link'><a href="TimeSpan/RelativeTime.html#initialize-instance_method" title="TimeSpan::RelativeTime#initialize (method)">#initialize</a></span>
|
261
293
|
|
262
|
-
<small>TimeSpan::
|
294
|
+
<small>TimeSpan::RelativeTime</small>
|
263
295
|
|
264
296
|
</li>
|
265
297
|
|
@@ -305,17 +337,17 @@
|
|
305
337
|
|
306
338
|
|
307
339
|
<li class="r2 ">
|
308
|
-
<span class='object_link'><a href="TimeSpan/
|
340
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#name-instance_method" title="TimeSpan::TimeSpan#name (method)">#name</a></span>
|
309
341
|
|
310
|
-
<small>TimeSpan::
|
342
|
+
<small>TimeSpan::TimeSpan</small>
|
311
343
|
|
312
344
|
</li>
|
313
345
|
|
314
346
|
|
315
347
|
<li class="r1 ">
|
316
|
-
<span class='object_link'><a href="TimeSpan/
|
348
|
+
<span class='object_link'><a href="TimeSpan/TimeLine.html#name-instance_method" title="TimeSpan::TimeLine#name (method)">#name</a></span>
|
317
349
|
|
318
|
-
<small>TimeSpan::
|
350
|
+
<small>TimeSpan::TimeLine</small>
|
319
351
|
|
320
352
|
</li>
|
321
353
|
|
@@ -337,15 +369,15 @@
|
|
337
369
|
|
338
370
|
|
339
371
|
<li class="r2 ">
|
340
|
-
<span class='object_link'><a href="TimeSpan/
|
372
|
+
<span class='object_link'><a href="TimeSpan/RelativeTime.html#reference_to-instance_method" title="TimeSpan::RelativeTime#reference_to (method)">#reference_to</a></span>
|
341
373
|
|
342
|
-
<small>TimeSpan::
|
374
|
+
<small>TimeSpan::RelativeTime</small>
|
343
375
|
|
344
376
|
</li>
|
345
377
|
|
346
378
|
|
347
379
|
<li class="r1 ">
|
348
|
-
<span class='object_link'><a href="TimeSpan/TimeLine.html#
|
380
|
+
<span class='object_link'><a href="TimeSpan/TimeLine.html#relative_times-instance_method" title="TimeSpan::TimeLine#relative_times (method)">#relative_times</a></span>
|
349
381
|
|
350
382
|
<small>TimeSpan::TimeLine</small>
|
351
383
|
|
@@ -353,7 +385,7 @@
|
|
353
385
|
|
354
386
|
|
355
387
|
<li class="r2 ">
|
356
|
-
<span class='object_link'><a href="TimeSpan/TimeLine.html#
|
388
|
+
<span class='object_link'><a href="TimeSpan/TimeLine.html#remove-instance_method" title="TimeSpan::TimeLine#remove (method)">#remove</a></span>
|
357
389
|
|
358
390
|
<small>TimeSpan::TimeLine</small>
|
359
391
|
|
@@ -361,15 +393,15 @@
|
|
361
393
|
|
362
394
|
|
363
395
|
<li class="r1 ">
|
364
|
-
<span class='object_link'><a href="TimeSpan/
|
396
|
+
<span class='object_link'><a href="TimeSpan/TimeLine.html#spans-instance_method" title="TimeSpan::TimeLine#spans (method)">#spans</a></span>
|
365
397
|
|
366
|
-
<small>TimeSpan::
|
398
|
+
<small>TimeSpan::TimeLine</small>
|
367
399
|
|
368
400
|
</li>
|
369
401
|
|
370
402
|
|
371
403
|
<li class="r2 ">
|
372
|
-
<span class='object_link'><a href="TimeSpan/TimeSpan.html#
|
404
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#starts-instance_method" title="TimeSpan::TimeSpan#starts (method)">#starts</a></span>
|
373
405
|
|
374
406
|
<small>TimeSpan::TimeSpan</small>
|
375
407
|
|
@@ -377,7 +409,7 @@
|
|
377
409
|
|
378
410
|
|
379
411
|
<li class="r1 ">
|
380
|
-
<span class='object_link'><a href="TimeSpan/TimeSpan.html#
|
412
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#starts_after%3F-instance_method" title="TimeSpan::TimeSpan#starts_after? (method)">#starts_after?</a></span>
|
381
413
|
|
382
414
|
<small>TimeSpan::TimeSpan</small>
|
383
415
|
|
@@ -385,7 +417,7 @@
|
|
385
417
|
|
386
418
|
|
387
419
|
<li class="r2 ">
|
388
|
-
<span class='object_link'><a href="TimeSpan/TimeSpan.html#
|
420
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#starts_after_other_ends%3F-instance_method" title="TimeSpan::TimeSpan#starts_after_other_ends? (method)">#starts_after_other_ends?</a></span>
|
389
421
|
|
390
422
|
<small>TimeSpan::TimeSpan</small>
|
391
423
|
|
@@ -393,7 +425,7 @@
|
|
393
425
|
|
394
426
|
|
395
427
|
<li class="r1 ">
|
396
|
-
<span class='object_link'><a href="TimeSpan/TimeSpan.html#
|
428
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#starts_as_other_ends%3F-instance_method" title="TimeSpan::TimeSpan#starts_as_other_ends? (method)">#starts_as_other_ends?</a></span>
|
397
429
|
|
398
430
|
<small>TimeSpan::TimeSpan</small>
|
399
431
|
|
@@ -401,7 +433,7 @@
|
|
401
433
|
|
402
434
|
|
403
435
|
<li class="r2 ">
|
404
|
-
<span class='object_link'><a href="TimeSpan/TimeSpan.html#
|
436
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#starts_before%3F-instance_method" title="TimeSpan::TimeSpan#starts_before? (method)">#starts_before?</a></span>
|
405
437
|
|
406
438
|
<small>TimeSpan::TimeSpan</small>
|
407
439
|
|
@@ -409,7 +441,7 @@
|
|
409
441
|
|
410
442
|
|
411
443
|
<li class="r1 ">
|
412
|
-
<span class='object_link'><a href="TimeSpan/TimeSpan.html#
|
444
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#starts_before_or_with%3F-instance_method" title="TimeSpan::TimeSpan#starts_before_or_with? (method)">#starts_before_or_with?</a></span>
|
413
445
|
|
414
446
|
<small>TimeSpan::TimeSpan</small>
|
415
447
|
|
@@ -417,7 +449,7 @@
|
|
417
449
|
|
418
450
|
|
419
451
|
<li class="r2 ">
|
420
|
-
<span class='object_link'><a href="TimeSpan/TimeSpan.html#
|
452
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#starts_on_or_after%3F-instance_method" title="TimeSpan::TimeSpan#starts_on_or_after? (method)">#starts_on_or_after?</a></span>
|
421
453
|
|
422
454
|
<small>TimeSpan::TimeSpan</small>
|
423
455
|
|
@@ -425,7 +457,7 @@
|
|
425
457
|
|
426
458
|
|
427
459
|
<li class="r1 ">
|
428
|
-
<span class='object_link'><a href="TimeSpan/TimeSpan.html#
|
460
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#starts_with%3F-instance_method" title="TimeSpan::TimeSpan#starts_with? (method)">#starts_with?</a></span>
|
429
461
|
|
430
462
|
<small>TimeSpan::TimeSpan</small>
|
431
463
|
|
@@ -441,9 +473,9 @@
|
|
441
473
|
|
442
474
|
|
443
475
|
<li class="r1 ">
|
444
|
-
<span class='object_link'><a href="TimeSpan/
|
476
|
+
<span class='object_link'><a href="TimeSpan/TimeSpan.html#time_line-instance_method" title="TimeSpan::TimeSpan#time_line (method)">#time_line</a></span>
|
445
477
|
|
446
|
-
<small>TimeSpan::
|
478
|
+
<small>TimeSpan::TimeSpan</small>
|
447
479
|
|
448
480
|
</li>
|
449
481
|
|
@@ -456,6 +488,14 @@
|
|
456
488
|
</li>
|
457
489
|
|
458
490
|
|
491
|
+
<li class="r1 ">
|
492
|
+
<span class='object_link'><a href="TimeSpan/RelativeTime.html#to_s-instance_method" title="TimeSpan::RelativeTime#to_s (method)">#to_s</a></span>
|
493
|
+
|
494
|
+
<small>TimeSpan::RelativeTime</small>
|
495
|
+
|
496
|
+
</li>
|
497
|
+
|
498
|
+
|
459
499
|
</ul>
|
460
500
|
</div>
|
461
501
|
</body>
|
data/lib/time_span.rb
CHANGED
@@ -32,6 +32,11 @@ module TimeSpan
|
|
32
32
|
starting_at.kind_of?(RelativeTime) && ending_at.kind_of?(RelativeTime) && (starting_at <= ending_at)
|
33
33
|
end
|
34
34
|
|
35
|
+
# @raise [NotImplementedError] could create illegal objects by gem rules
|
36
|
+
def clone
|
37
|
+
raise NotImplementedError, "Cannot use base Ruby clone which can create illegal objects by gem rules."
|
38
|
+
end
|
39
|
+
|
35
40
|
# returns the 'statuses' for the start and end times
|
36
41
|
# @return start and end time statuses in a hash with key is self
|
37
42
|
def endpoint_statuses
|
@@ -44,98 +49,98 @@ module TimeSpan
|
|
44
49
|
# #
|
45
50
|
#######################################################################################################
|
46
51
|
|
47
|
-
# tests if one TimeSpan starts before another (on the same TimeLine)
|
52
|
+
# tests if one TimeSpan starts before another (on the same TimeLine -- delegated to RelativeTime)
|
48
53
|
# @param [TimeSpan::TimeSpan] other_time_span the TimeSpan being compared to self
|
49
54
|
# @return true if self starts before b starts
|
50
55
|
def starts_before?(other_time_span)
|
51
56
|
starts < other_time_span.starts
|
52
57
|
end
|
53
58
|
|
54
|
-
# tests if one TimeSpan starts after another (on the same TimeLine)
|
59
|
+
# tests if one TimeSpan starts after another (on the same TimeLine -- delegated to RelativeTime)
|
55
60
|
# @param (see #starts_before? )
|
56
61
|
# @return true if self starts after other_time_span starts
|
57
62
|
def starts_after?(other_time_span)
|
58
63
|
starts > other_time_span.starts
|
59
64
|
end
|
60
65
|
|
61
|
-
# tests if one TimeSpan starts with or after another (on the same TimeLine)
|
66
|
+
# tests if one TimeSpan starts with or after another (on the same TimeLine -- delegated to RelativeTime)
|
62
67
|
# @param (see #starts_before? )
|
63
68
|
# @return true if self starts on or after other_time_span starts
|
64
69
|
def starts_on_or_after?(other_time_span)
|
65
70
|
starts >= other_time_span.starts
|
66
71
|
end
|
67
72
|
|
68
|
-
# tests if one TimeSpan starts at the same time as another (on the same TimeLine)
|
73
|
+
# tests if one TimeSpan starts at the same time as another (on the same TimeLine -- delegated to RelativeTime)
|
69
74
|
# @param (see #starts_before? )
|
70
75
|
# @return true if self starts at the same time as other_time_span starts
|
71
76
|
def starts_with?(other_time_span)
|
72
77
|
starts == other_time_span.starts
|
73
78
|
end
|
74
79
|
|
75
|
-
# tests if one TimeSpan starts before or at the same time as another (on the same TimeLine)
|
80
|
+
# tests if one TimeSpan starts before or at the same time as another (on the same TimeLine -- delegated to RelativeTime)
|
76
81
|
# @param (see #starts_before? )
|
77
82
|
# @return true if self starts before or at the same time as other_time_span starts
|
78
83
|
def starts_before_or_with?(other_time_span)
|
79
84
|
starts <= other_time_span.starts
|
80
85
|
end
|
81
86
|
|
82
|
-
# tests if one TimeSpan ends before another starts (on the same TimeLine)
|
87
|
+
# tests if one TimeSpan ends before another starts (on the same TimeLine -- delegated to RelativeTime)
|
83
88
|
# @param (see #starts_before? )
|
84
89
|
# @return true if self ends before another time_span starts
|
85
90
|
def ends_before?(other_time_span)
|
86
91
|
ends < other_time_span.ends
|
87
92
|
end
|
88
93
|
|
89
|
-
# tests if one TimeSpan end before or at the same time as another ends (on the same TimeLine)
|
94
|
+
# tests if one TimeSpan end before or at the same time as another ends (on the same TimeLine -- delegated to RelativeTime)
|
90
95
|
# @param (see #starts_before? )
|
91
96
|
# @return true if self ends before or at the same time as another time_span ends
|
92
97
|
def ends_on_or_before?(other_time_span)
|
93
98
|
ends <= other_time_span.ends
|
94
99
|
end
|
95
100
|
|
96
|
-
# tests if one TimeSpan ends after or at the same time as another (on the same TimeLine)
|
101
|
+
# tests if one TimeSpan ends after or at the same time as another (on the same TimeLine -- delegated to RelativeTime)
|
97
102
|
# @param (see #starts_before? )
|
98
103
|
# @return true if self ends after or at the same time as another time_span ends
|
99
104
|
def ends_on_or_after?(other_time_span)
|
100
105
|
ends >= other_time_span.ends
|
101
106
|
end
|
102
107
|
|
103
|
-
# tests if one TimeSpan ends after another (on the same TimeLine)
|
108
|
+
# tests if one TimeSpan ends after another (on the same TimeLine -- delegated to RelativeTime)
|
104
109
|
# @param (see #starts_before? )
|
105
110
|
# @return true if self ends after another time_span ends
|
106
111
|
def ends_after?(other_time_span)
|
107
112
|
ends > other_time_span.ends
|
108
113
|
end
|
109
114
|
|
110
|
-
# tests if one TimeSpan ends at the same time as another (on the same TimeLine)
|
115
|
+
# tests if one TimeSpan ends at the same time as another (on the same TimeLine -- delegated to RelativeTime)
|
111
116
|
# @param (see #starts_before? )
|
112
117
|
# @return true if self ends at the same time as another time_span ends
|
113
118
|
def ends_with?(other_time_span)
|
114
119
|
ends == other_time_span.ends
|
115
120
|
end
|
116
121
|
|
117
|
-
# tests if one TimeSpan ends before another starts (on the same TimeLine)
|
122
|
+
# tests if one TimeSpan ends before another starts (on the same TimeLine -- delegated to RelativeTime)
|
118
123
|
# @param (see #starts_before? )
|
119
124
|
# @return true if self ends before another time_span starts
|
120
125
|
def ends_before_other_starts?(other_time_span)
|
121
126
|
ends < other_time_span.starts
|
122
127
|
end
|
123
128
|
|
124
|
-
# tests if one TimeSpan ends at the same time as another starts (on the same TimeLine)
|
129
|
+
# tests if one TimeSpan ends at the same time as another starts (on the same TimeLine -- delegated to RelativeTime)
|
125
130
|
# @param (see #starts_before? )
|
126
131
|
# @return true if self ends at the same time as another time_span starts (no gap)
|
127
132
|
def ends_as_other_starts?(other_time_span)
|
128
133
|
ends == other_time_span.starts
|
129
134
|
end
|
130
135
|
|
131
|
-
# tests if one TimeSpan ends at the same time as another (on the same TimeLine)
|
136
|
+
# tests if one TimeSpan ends at the same time as another (on the same TimeLine -- delegated to RelativeTime)
|
132
137
|
# @param (see #starts_before? )
|
133
138
|
# @return true if self ends at the same time as another time_span ends
|
134
139
|
def starts_after_other_ends?(other_time_span)
|
135
140
|
starts > other_time_span.ends
|
136
141
|
end
|
137
142
|
|
138
|
-
# tests if one TimeSpan starts at the same time as another ends (on the same TimeLine)
|
143
|
+
# tests if one TimeSpan starts at the same time as another ends (on the same TimeLine -- delegated to RelativeTime)
|
139
144
|
# @param (see #starts_before? )
|
140
145
|
# @return true if self starts at the same time as another time_span ends
|
141
146
|
def starts_as_other_ends?(other_time_span)
|
@@ -152,21 +157,21 @@ module TimeSpan
|
|
152
157
|
## unless it is meant < XOR =
|
153
158
|
|
154
159
|
|
155
|
-
# tests if one TimeSpan is the same as another (on the same TimeLine)
|
160
|
+
# tests if one TimeSpan is the same as another (on the same TimeLine -- delegated to RelativeTime)
|
156
161
|
# @param (see #starts_before? )
|
157
162
|
# @return [Boolean] true if same as the other
|
158
163
|
def == (other_time_span)
|
159
164
|
ends_with?(other_time_span) && starts_with?(other_time_span)
|
160
165
|
end
|
161
166
|
|
162
|
-
# tests if one TimeSpan is not the same as another (on the same TimeLine)
|
167
|
+
# tests if one TimeSpan is not the same as another (on the same TimeLine -- delegated to RelativeTime)
|
163
168
|
# @param (see #starts_before? )
|
164
169
|
# @return [Boolean] true if not same as the other
|
165
170
|
def != (other_time_span)
|
166
171
|
!end_with(other_time_span) || !starts_with(other_time_span)
|
167
172
|
end
|
168
173
|
|
169
|
-
# tests if one TimeSpan ends before another starts (on the same TimeLine)
|
174
|
+
# tests if one TimeSpan ends before another starts (on the same TimeLine -- delegated to RelativeTime)
|
170
175
|
# alias for '#ends_before_other_starts'
|
171
176
|
# @param (see #starts_before? )
|
172
177
|
# @return [Boolean] true if self ends before another starts
|
@@ -174,7 +179,7 @@ module TimeSpan
|
|
174
179
|
ends_before_other_starts?(other_time_span)
|
175
180
|
end
|
176
181
|
|
177
|
-
# tests if one TimeSpan starts after another ends (on the same TimeLine)
|
182
|
+
# tests if one TimeSpan starts after another ends (on the same TimeLine -- delegated to RelativeTime)
|
178
183
|
# alias for '#starts_after_other_ends'
|
179
184
|
# @param (see #starts_before? )
|
180
185
|
# @return [Boolean] true if self starts after another ends
|
@@ -182,28 +187,28 @@ module TimeSpan
|
|
182
187
|
starts_after_other_ends?(other_time_span)
|
183
188
|
end
|
184
189
|
|
185
|
-
# tests if one TimeSpan is contained within another (on the same TimeLine)
|
190
|
+
# tests if one TimeSpan is contained within another (on the same TimeLine -- delegated to RelativeTime)
|
186
191
|
# @param (see #starts_before? )
|
187
192
|
# @return true if self contained inside another
|
188
193
|
def contained_fully_inside?(other_time_span)
|
189
194
|
starts_after?(other_time_span) && ends_before?(other_time_span)
|
190
195
|
end
|
191
196
|
|
192
|
-
# tests if one TimeSpan is contained within another, possibly begining as or ends as another (on the same TimeLine)
|
197
|
+
# tests if one TimeSpan is contained within another, possibly begining as or ends as another (on the same TimeLine -- delegated to RelativeTime)
|
193
198
|
# @param (see #starts_before? )
|
194
199
|
# @return true if self contained inside another, including same endpoints
|
195
200
|
def contained_inside?(other_time_span)
|
196
201
|
starts_on_or_after?(other_time_span) && ends_on_or_before?(other_time_span)
|
197
202
|
end
|
198
203
|
|
199
|
-
# tests if one TimeSpan contains another (on the same TimeLine)
|
204
|
+
# tests if one TimeSpan contains another (on the same TimeLine -- delegated to RelativeTime)
|
200
205
|
# @param (see #starts_before? )
|
201
206
|
# @return true if self contains another
|
202
207
|
def contains_fully?(other_time_span)
|
203
208
|
starts_before?(other_time_span) && ends_after?(other_time_span)
|
204
209
|
end
|
205
210
|
|
206
|
-
# tests if one TimeSpan contains within another (on the same TimeLine)
|
211
|
+
# tests if one TimeSpan contains within another (on the same TimeLine -- delegated to RelativeTime)
|
207
212
|
# @param (see #starts_before? )
|
208
213
|
# @return true if self contains another
|
209
214
|
def contains?(other_time_span)
|
@@ -245,6 +250,21 @@ module TimeSpan
|
|
245
250
|
@spans = []
|
246
251
|
end
|
247
252
|
|
253
|
+
# @raise [NotImplementedError] Cannot use base Ruby clone which can create illegal objects by gem rules.
|
254
|
+
def clone
|
255
|
+
raise NotImplementedError, "Cannot use base Ruby clone which can create illegal objects by gem rules."
|
256
|
+
end
|
257
|
+
|
258
|
+
# test for value equality. Checking span trait is redundant -- can't have spans without times'
|
259
|
+
# @param [TimeSpan::TimeLine] TimeLine being compared to
|
260
|
+
# @return [Boolean] true if name is equal and all other attributes are empty.
|
261
|
+
def == (other_timeline)
|
262
|
+
(object_id == other_timeline.object_id) ||
|
263
|
+
(@name == other_timeline.name) &&
|
264
|
+
(@line.empty? && @indices_of.empty? && @spans.empty?) &&
|
265
|
+
(other_timeline.line.empty? && other_timeline.indices_of.empty? && other_timeline.spans.empty?)
|
266
|
+
end
|
267
|
+
|
248
268
|
# returns the TimeLine's name
|
249
269
|
# @return [String] TimeLine's name'
|
250
270
|
def to_s
|
@@ -403,6 +423,13 @@ module TimeSpan
|
|
403
423
|
@reference_to= ref
|
404
424
|
end
|
405
425
|
|
426
|
+
# @raise [NotImplementedError] cannot do without much more work
|
427
|
+
def clone
|
428
|
+
raise NotImplementedError, "Cannot use base Ruby clone which can create illegal objects by gem rules."
|
429
|
+
end
|
430
|
+
|
431
|
+
|
432
|
+
|
406
433
|
# @return [String] the string representation of referenced object
|
407
434
|
def to_s
|
408
435
|
@reference_to.to_s
|