Class: Animoto::Resources::Jobs::Base Abstract

Inherits:
Base
  • Object
show all
Defined in:
lib/animoto/resources/jobs/base.rb

Overview

This class is abstract.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#endpoint, #initialize, load, #load, new, original_new, register

Methods included from Support::StandardEnvelope

find_class_for, included

Constructor Details

This class inherits a constructor from Animoto::Resources::Base

Instance Attribute Details

#errorsArray<Animoto::Error> (readonly)

Errors associated with this job.

Returns:



36
37
38
# File 'lib/animoto/resources/jobs/base.rb', line 36

def errors
  @errors
end

#stateString (readonly)

The state of this job.

Returns:

  • (String)


32
33
34
# File 'lib/animoto/resources/jobs/base.rb', line 32

def state
  @state
end

#urlString (readonly)

The URL for this job.

Returns:

  • (String)


28
29
30
# File 'lib/animoto/resources/jobs/base.rb', line 28

def url
  @url
end

Class Method Details

.endpoint(path = nil) ⇒ Object



18
19
20
# File 'lib/animoto/resources/jobs/base.rb', line 18

def self.endpoint path = nil
  super || infer_endpoint
end

.infer_content_typeString

Returns:

  • (String)


14
15
16
# File 'lib/animoto/resources/jobs/base.rb', line 14

def self.infer_content_type
  super + '_job'
end

.infer_endpointObject



22
23
24
# File 'lib/animoto/resources/jobs/base.rb', line 22

def self.infer_endpoint
  "/jobs/#{name.split('::').last.underscore}"
end

.unpack_standard_envelope(body) ⇒ Hash{Symbol=>Object}

Returns:

  • (Hash{Symbol=>Object})


9
10
11
# File 'lib/animoto/resources/jobs/base.rb', line 9

def self.unpack_standard_envelope body
  super.merge(:state => unpack_payload(body)['state'])
end

Instance Method Details

#completed?Boolean

Returns true if the state of this job is ‘completed’.

Returns:

  • (Boolean)

    whether or not the job is completed



48
49
50
# File 'lib/animoto/resources/jobs/base.rb', line 48

def completed?
  @state == 'completed'
end

#failed?Boolean

Returns true if the state of this job is ‘failed’.

Returns:

  • (Boolean)

    whether or not the job has failed.



41
42
43
# File 'lib/animoto/resources/jobs/base.rb', line 41

def failed?
  @state == 'failed'
end

#instantiate(attributes = {}) ⇒ Jobs::Base

Returns:

See Also:



61
62
63
64
# File 'lib/animoto/resources/jobs/base.rb', line 61

def instantiate attributes = {}
  @state  = attributes[:state]
  super
end

#pending?Boolean

Returns true if the job is neither failed or completed.

Returns:

  • (Boolean)

    whether or not the job is still pending



55
56
57
# File 'lib/animoto/resources/jobs/base.rb', line 55

def pending?
  !failed? && !completed?
end