m3u8 0.3.0 → 0.3.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: 941d9ae1544d5853fa64790089c269ce9b7cdc9c
4
- data.tar.gz: fc32d9311ab491b6049b3a9c27ec6757886237d1
3
+ metadata.gz: 076a51812bf0e0b15592085e11cdbd8c16f891a0
4
+ data.tar.gz: deb1623d472e42656015eee0db7b98d065524db9
5
5
  SHA512:
6
- metadata.gz: e5bb40055129102f6b578533fcd0eb2904e9f43b7bfd3d5a9e6e2f14440095d401fbd4cb0fc04c10920ab60195703a5a7d7c1a94cfaafe939d093fbabe5e3521
7
- data.tar.gz: bb47741dc6419161bb23e46c8c56478e978d2a6c71757b4665e80394ce74c676e078a8925de7601a8fc77e67561b2968fff5a87792d6e390c52d7f89dba4504f
6
+ metadata.gz: b60b8c3ac32179a37c3bbbc4ee5dbbfd15c31b37e8b0e24da79f831040effe821bb567f3bd99003dab2405ca3bc41d34a284b4431274ae772883227333292141
7
+ data.tar.gz: fc80b8e642ce134f7af812d421453d8a1fa198d00ea183b178ce217f8594512ca8c11754e8b073d635a5bb66f15239ac82080208fc07c62e7dda1a77c2ee3443
data/lib/m3u8/playlist.rb CHANGED
@@ -38,6 +38,14 @@ module M3u8
38
38
  true
39
39
  end
40
40
 
41
+ def duration
42
+ duration = 0.0
43
+ items.each do |item|
44
+ duration += item.duration if item.is_a?(M3u8::SegmentItem)
45
+ end
46
+ duration
47
+ end
48
+
41
49
  private
42
50
 
43
51
  def assign_options(options)
data/lib/m3u8/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module M3u8
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -194,4 +194,18 @@ describe M3u8::Playlist do
194
194
  expect(playlist.master?).to be true
195
195
  expect(playlist.items.size).to eq 6
196
196
  end
197
+
198
+ it 'should return the total duration of a playlist' do
199
+ playlist = M3u8::Playlist.new
200
+ item = M3u8::SegmentItem.new(duration: 10.991, segment: 'test_01.ts')
201
+ playlist.items.push item
202
+ item = M3u8::SegmentItem.new(duration: 9.891, segment: 'test_02.ts')
203
+ playlist.items.push item
204
+ item = M3u8::SegmentItem.new(duration: 10.556, segment: 'test_03.ts')
205
+ playlist.items.push item
206
+ item = M3u8::SegmentItem.new(duration: 8.790, segment: 'test_04.ts')
207
+ playlist.items.push item
208
+
209
+ expect(playlist.duration.round(3)).to eq 40.228
210
+ end
197
211
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m3u8
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Deckard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-26 00:00:00.000000000 Z
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler