Class: VTools::Job
- Inherits:
-
Object
- Object
- VTools::Job
- Defined in:
- lib/vtools/job.rb
Overview
job instance
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#video ⇒ Object
readonly
Returns the value of attribute video.
Instance Method Summary collapse
-
#execute ⇒ Object
execute job.
-
#initialize(config) ⇒ Job
constructor
A new instance of Job.
-
#validate(options) ⇒ Object
parse video options.
Constructor Details
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/vtools/job.rb', line 7 def id @id end |
#video ⇒ Object (readonly)
Returns the value of attribute video.
7 8 9 |
# File 'lib/vtools/job.rb', line 7 def video @video end |
Instance Method Details
#execute ⇒ Object
execute job
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vtools/job.rb', line 16 def execute # start hook Hook.exec :job_started, @video, @config.action result = @video.get_info # we always get info case @config.action when /^convert$/i result = @video.convert @config.setup # will return video when /^thumbs$/i result = @video.create_thumbs @config.setup # will return thumbs array end # final hook Hook.exec :job_finished, result, @video, @config.action result end |
#validate(options) ⇒ Object
parse video options
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vtools/job.rb', line 35 def validate unless .action =~ /^convert|thumbs|info$/ && .file && !.file.empty? raise ConfigError, "Invalid action (config: #{.marshal_dump})" else return if .action =~ /^info$/ # empty set error raise ConfigError, "Configuration is empty" if !.setup || .setup.empty? end end |