Class: CloudPrint::PrintJob
- Inherits:
-
Object
- Object
- CloudPrint::PrintJob
- Defined in:
- lib/cloudprint/print_job.rb
Defined Under Namespace
Modules: Util
Constant Summary collapse
- STATUSES =
%w{QUEUED IN_PROGRESS DONE ERROR SUBMITTED}
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #delete! ⇒ Object
-
#initialize(client, data) ⇒ PrintJob
constructor
A new instance of PrintJob.
- #method_missing(meth, *args, &block) ⇒ Object
- #refresh! ⇒ Object
Constructor Details
#initialize(client, data) ⇒ PrintJob
Returns a new instance of PrintJob.
13 14 15 16 |
# File 'lib/cloudprint/print_job.rb', line 13 def initialize(client, data) @client = client @data = data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/cloudprint/print_job.rb', line 28 def method_missing(meth, *args, &block) if @data.has_key?(meth) @data[meth] elsif STATUSES.map{ |s| s.downcase + '?' }.include?(meth.to_s) @data[:status].downcase == meth.to_s.chop else super end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/cloudprint/print_job.rb', line 5 def client @client end |
Class Method Details
.new_from_response(client, response_hash) ⇒ Object
8 9 10 |
# File 'lib/cloudprint/print_job.rb', line 8 def new_from_response client, response_hash new client, Util.normalize_response_data(response_hash) end |
Instance Method Details
#delete! ⇒ Object
23 24 25 26 |
# File 'lib/cloudprint/print_job.rb', line 23 def delete! response = client.connection.get('/deletejob', { :jobid => id }) response['success'] || raise(RequestError, response['message']) end |
#refresh! ⇒ Object
18 19 20 21 |
# File 'lib/cloudprint/print_job.rb', line 18 def refresh! @data = Util.normalize_response_data(client.print_jobs.find_by_id(id)) self end |