time_frame 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36e147ffd05688d225d98d98b03df2055f8705fa
4
- data.tar.gz: 52ce6f9719d59c49101b5eae4c25efa6f6bb90af
3
+ metadata.gz: 956de9d650db7ad301e9b4b903cd330b0630d866
4
+ data.tar.gz: 32c2a3d2249e19ee5ac6ad6335d15952c9278816
5
5
  SHA512:
6
- metadata.gz: 8324b87fa0ad4685d2d793922f2a45923f16bad5fd2582534ad0df5ad9fa4bb77669cb79521836506c79e17b9dad0fc74a1af8e822c5e28fcb30a13fbc07042a
7
- data.tar.gz: 3ffca269f990f2ecfe62d2beed4ac25bf5592b749ff0e71fb4aef019ff24741f6b25f231edde6c89ffc55d70abcc903b69e1a229db0c44084012d56522f584a8
6
+ metadata.gz: 0b1fe690605128abd552bb893a6e4176343c453738f92efa9c935b8e7876d89ed358ca8ecf155f0af8ddd2d1e6b23ec712a5a778b0fd3c3700645eeab2cf8845
7
+ data.tar.gz: 92c452c7bcd63b6651d545a3d41ea15b11e48d575b02899a54ebe0726d0668fee25d54a0ecb6c2e79fbbd6f06b277fd26818ee4eff896f521f573c2d048308b0
data/Gemfile CHANGED
@@ -5,4 +5,5 @@ gemspec
5
5
 
6
6
  group :development, :test do
7
7
  gem 'geminabox'
8
+ gem 'byebug'
8
9
  end
@@ -10,12 +10,13 @@ class TimeFrame
10
10
 
11
11
  def unite
12
12
  frames = @sorted ? @time_frames : @time_frames.sort_by(&:min)
13
- frames.each_with_object([]) do |frame, result|
14
- last_frame = result.last
15
- if last_frame && last_frame.cover?(frame.min)
16
- result[-1] = TimeFrame.new(min: last_frame.min, max: frame.max)
13
+ frames.each_with_object([]) do |next_time_frame, result|
14
+ last_time_frame = result.last
15
+ if last_time_frame && last_time_frame.cover?(next_time_frame.min)
16
+ max = [last_time_frame.max, next_time_frame.max].max
17
+ result[-1] = TimeFrame.new(min: last_time_frame.min, max: max)
17
18
  else
18
- result << frame
19
+ result << next_time_frame
19
20
  end
20
21
  end
21
22
  end
@@ -1,5 +1,5 @@
1
1
  # Encoding: utf-8
2
2
  # gem version
3
3
  class TimeFrame
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
@@ -395,6 +395,15 @@ describe TimeFrame do
395
395
  subject { TimeFrame.union([time_frame1, time_frame2]) }
396
396
  it { should eq expected }
397
397
  end
398
+ context 'that are overlapping and first contains the second' do
399
+ let(:time_frame1) { TimeFrame.new(min: time, duration: 3.hours) }
400
+ let(:time_frame2) do
401
+ TimeFrame.new(min: time + 1.hour, duration: 1.hour)
402
+ end
403
+ let(:expected) { [time_frame1] }
404
+ subject { TimeFrame.union([time_frame1, time_frame2]) }
405
+ it { should eq expected }
406
+ end
398
407
  context 'that are disjoint' do
399
408
  let(:time_frame1) { TimeFrame.new(min: time, duration: 2.hours) }
400
409
  let(:time_frame2) { time_frame1.shift_by(3.hours) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_frame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Derichs
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-23 00:00:00.000000000 Z
13
+ date: 2014-07-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake