ts 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ts.rb +2 -2
  3. data/test/test_ts.rb +4 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff34df04c16e070099bd33b7dc8c555e71da1ed7
4
- data.tar.gz: 490cf55edfe90f090d8f90856bce8bf73fb72620
3
+ metadata.gz: db5a9916d1ab3898e81acb156d564a1d17e18fa5
4
+ data.tar.gz: 431ae5e7fdc9940859744d37bedc8b121cd82f56
5
5
  SHA512:
6
- metadata.gz: 2a9300080f2d311dae22a4420e783747ee00b9fc4015b9b36041c314f01fff564eb4788ac0e64369b3f71880eeb4e46deae5ec59e020ed6d034b342ba4ed552e
7
- data.tar.gz: 500647b618d9cbe60051925781980f60ca7053d6683111f3a8ce19254e6bfcc77542cef265ed998f5985f15ee623b37e43757c025d61fa6f59ae692c2279e25d
6
+ metadata.gz: acbe9bc53d88e4535beac23f167b1bcada845bb529bb5571b98ee557004a4859a00c466b700f84bf15c4bf043f7e5aba0e9eb50af4cefe9807cf0276f5f5a8a0
7
+ data.tar.gz: d80c39981b0e42c721d622315fafa86efe7a961c5c9368903d7716fed491a0611463d6d3ebbcb8e4a3e3c26fc0eb96f52316cea82e6c1565a166864453fd8f08
data/lib/ts.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  #
7
7
  class TS
8
8
 
9
- Version = "1.0.2"
9
+ Version = "1.0.3"
10
10
 
11
11
  include Enumerable
12
12
 
@@ -134,10 +134,10 @@ class TS
134
134
  # +time+ the time boundary
135
135
  def before time
136
136
  idx = nearest(time)
137
+ return TS.new([]) if idx <= 0
137
138
  if time_at(idx) < time
138
139
  idx += 1
139
140
  end
140
-
141
141
  TS.new(@data[0..idx-1])
142
142
  end
143
143
 
@@ -36,10 +36,14 @@ class TSTest < Test::Unit::TestCase
36
36
 
37
37
  def test_after
38
38
  assert_equal 999, @ts.after(1000).size
39
+ assert_equal 1000, @ts.after(-1).size
40
+ assert_equal 0, @ts.after(1000 * 1000 + 1).size
39
41
  end
40
42
 
41
43
  def test_before
42
44
  assert_equal 1, @ts.before(2000).size
45
+ assert_equal 1000, @ts.before(1000 * 1000 + 1).size
46
+ assert_equal 0, @ts.before(0).size
43
47
  end
44
48
 
45
49
  def test_timestamps
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Simpson