Class: Titlekit::Job
- Inherits:
-
Object
- Object
- Titlekit::Job
- Defined in:
- lib/titlekit/job.rb
Instance Attribute Summary collapse
-
#haves ⇒ Array<Have>
readonly
Returns everything you Have.
-
#report ⇒ Array<String>
readonly
Returns the job report, which documents the direct cause of failures and any other unusual events that occur on the job.
-
#wants ⇒ Array<Want>
readonly
Returns everything you Want.
Instance Method Summary collapse
-
#have(*_args, template: nil, &block) ⇒ Have
Adds a new Have specification to your job.
-
#initialize ⇒ Job
constructor
Starts a new job.
-
#run ⇒ Boolean
Runs the job.
-
#want(*args, template: nil, &block) ⇒ Want
Adds a new Want specification to your job.
Constructor Details
#initialize ⇒ Job
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/titlekit/job.rb', line 30 def initialize @haves = [] @wants = [] @report = [] require 'rchardet19' begin if Gem::Specification.find_by_name('charlock_holmes') require 'charlock_holmes' end rescue Gem::LoadError end end |
Instance Attribute Details
#haves ⇒ Array<Have> (readonly)
Returns everything you Have
10 11 12 |
# File 'lib/titlekit/job.rb', line 10 def haves @haves end |
#report ⇒ Array<String> (readonly)
Returns the job report, which documents the direct cause of failures and any other unusual events that occur on the job. (regardless if it failed or succeeded)
22 23 24 |
# File 'lib/titlekit/job.rb', line 22 def report @report end |
Instance Method Details
#have(*_args, template: nil, &block) ⇒ Have
Adds a new Have specification to your job.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/titlekit/job.rb', line 99 def have(*_args, template: nil, &block) specification = Have.new if template specification.fps = template.fps.clone specification.references = template.references.clone end if block if block.arity < 1 specification.instance_eval(&block) else block[specification] end end @haves << specification specification end |
#run ⇒ Boolean
Runs the job.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/titlekit/job.rb', line 49 def run @wants.each do |want| @haves.each do |have| import(have) retime(have, want) cull(have) group(have) want.subtitles += have.subtitles.clone end polish(want) export(want) end return true rescue AbortJob return false end |
#want(*args, template: nil, &block) ⇒ Want
Adds a new Want specification to your job.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/titlekit/job.rb', line 150 def want(*args, template: nil, &block) specification = Want.new if template specification.fps = template.fps.clone specification.references = template.references.clone end if block if block.arity < 1 specification.instance_eval(&block) else block[specification] end end @wants << specification specification end |