captions 1.1.0 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fa4cae69f6680c59e52b75923090285903649f8
4
- data.tar.gz: 35fbb9f01a03343b2f93edbef577f7b2f77fcfb6
3
+ metadata.gz: 8aaf29e28d6890736d40500f885c946f12b94573
4
+ data.tar.gz: ae528f8b011b5033b13741b3f1fdff94323f09d6
5
5
  SHA512:
6
- metadata.gz: 6219da7754d62b47c05fa21282f883160a493e21a42a4f630df69ecf49bf5fcaa428e58527a755163de0fd4482dbf84b1a1b1c6f0b6102fd43d5bc5c5645f68d
7
- data.tar.gz: a65e9445a54b9aeb2d0daeb3bd8a5a2cdba365e2832a60dbfb8cae1fbce7d7ba9efc4dc4dfae852e239644315b29e91f241addea555e88731a7db69bb54bc140
6
+ metadata.gz: e30036d4749fdae72ce8361be1476b43549047d3e264da85181ea28fcc0a09a0ac5aac092846ba7baeaca5da56a8285ec75bd0997e8cd00a4a57f2615011b831
7
+ data.tar.gz: e3d3fda2a92a78b906f7f6f910bfa66b9ebdd73c73e9934482b5ef6601e7a30b5e24924920eeb03968182545ec00f6443a7b307ad5d3e69b513ac2b6d877a084
data/README.md CHANGED
@@ -106,6 +106,15 @@ new_cues = s.cues { |c| c.start_time > 2000 }
106
106
  s.export_to_vtt('test.vtt', new_cues)
107
107
  ```
108
108
 
109
+ **Filter subtiltes and Export:**
110
+
111
+ Subtitles can be filtered with filter option. This returns a new `Captions` object. Once filters new object is created and cues for that becomes the result of the filter. This can be exported to other formats easily.
112
+
113
+ ```ruby
114
+ new_obj = s.filter { |c| c.start_time > 2000 }
115
+ new_obj.export_to_vtt('test.vtt')
116
+ ```
117
+
109
118
  ## Installation
110
119
 
111
120
  Add this line to your application's Gemfile:
data/lib/captions/base.rb CHANGED
@@ -75,6 +75,23 @@ module Captions
75
75
  end
76
76
  end
77
77
 
78
+ # This filters the subtitle based on the condition and returns
79
+ # a new object. A condition is mandatory to filter subtitles
80
+ # Usage:
81
+ # p.filter
82
+ # p.filter { |c| c.start_time > 1000 }
83
+ # p.filter { |c| c.end_time > 1000 }
84
+ # p.filter { |c| c.duration > 1000 }
85
+ #
86
+ # Filters and returns a Captions class rather than a cue list
87
+ def filter(&block)
88
+ if block_given?
89
+ base = self.class.new()
90
+ base.cues = fetch_result(&block)
91
+ return base
92
+ end
93
+ end
94
+
78
95
  # Moves subtitles by `n` milliseconds
79
96
  # Usage:
80
97
  # p.move_by(1000)
@@ -1,3 +1,3 @@
1
1
  module Captions
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: captions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - navin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-14 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec