Class: UEncode::Job

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/uencode/elements.rb

Constant Summary collapse

ATTRIBUTES =
[:source, :userdata, :notify]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Job

Returns a new instance of Job.



222
223
224
225
226
# File 'lib/uencode/elements.rb', line 222

def initialize(options)
  @video_output = VideoOutput.new options[:video_output] || {}
  @captures = []
  super
end

Class Method Details

.from_hash(hash) ⇒ Object



218
219
220
# File 'lib/uencode/elements.rb', line 218

def self.from_hash(hash)
  new({})
end

Instance Method Details

#<<(item) ⇒ Object



236
237
238
# File 'lib/uencode/elements.rb', line 236

def <<(item)
  @video_output.items << item
end

#add_capture(capture) ⇒ Object



240
241
242
# File 'lib/uencode/elements.rb', line 240

def add_capture(capture)
  @captures << capture
end

#configure_video_output {|@video_output| ... } ⇒ Object

Yields:

  • (@video_output)


228
229
230
# File 'lib/uencode/elements.rb', line 228

def configure_video_output
  yield @video_output      
end

#each(&block) ⇒ Object



244
245
246
# File 'lib/uencode/elements.rb', line 244

def each(&block)
  @video_output.each &block
end

#itemsObject



232
233
234
# File 'lib/uencode/elements.rb', line 232

def items
  @video_output.items
end

#to_xmlObject



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/uencode/elements.rb', line 248

def to_xml
  xml = %Q{
    <job>
      <customerkey>#{UEncode.customer_key}</customerkey>
      <source>#{source}</source>
      #{userdata.nil? ? "" : '<userdata>' + userdata + '</userdata>'}
      #{notify.nil? ? "" : '<notify>' + notify + '</notify>'}
      <outputs>
        #{@video_output.to_xml}
        #{@captures.inject("") { |s, cap| s << cap.to_xml }}
      </outputs>
    </job>
  }
  Nokogiri::XML(xml).to_xml
end