Class: Ferto::Callback
- Inherits:
-
Object
- Object
- Ferto::Callback
- Defined in:
- lib/ferto/callback.rb
Defined Under Namespace
Classes: ParserError
Instance Attribute Summary collapse
-
#download_url ⇒ String
readonly
The URL from which the resulting downloaded file can be fetched.
-
#error ⇒ String, NilClass
readonly
The error message of the download or nil if there was no error.
-
#extra ⇒ Hash
readonly
Any extra information sent by the client.
-
#job_id ⇒ String
readonly
The job id generated by the Downloader.
-
#resource_url ⇒ String
readonly
The original resource URL of the job.
-
#response_code ⇒ Integer
readonly
The status code returned by the upstream server when the download was attempted.
Instance Method Summary collapse
-
#download_successful? ⇒ Boolean
Whether the download job was successful.
-
#initialize(params) ⇒ Callback
constructor
A new instance of Callback.
-
#matching_url?(url) ⇒ Boolean
Determines whether the URL of the download is the same with the one the downloader used for the download.
-
#mime_error? ⇒ Boolean
Return true if there is a Mime type mismatch.
Constructor Details
#initialize(params) ⇒ Callback
Returns a new instance of Callback.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ferto/callback.rb', line 35 def initialize(params) params = parse(params) @success = params[:success] @error = params[:error] @extra = params[:extra] @download_url = params[:download_url] @resource_url = params[:resource_url] @job_id = params[:job_id] @response_code = params[:response_code] @mime_error = params[:mime_error] end |
Instance Attribute Details
#download_url ⇒ String (readonly)
Returns The URL from which the resulting downloaded file can be fetched.
12 13 14 |
# File 'lib/ferto/callback.rb', line 12 def download_url @download_url end |
#error ⇒ String, NilClass (readonly)
Returns The error message of the download or nil if there was no error.
5 6 7 |
# File 'lib/ferto/callback.rb', line 5 def error @error end |
#extra ⇒ Hash (readonly)
Returns Any extra information sent by the client.
8 9 10 |
# File 'lib/ferto/callback.rb', line 8 def extra @extra end |
#job_id ⇒ String (readonly)
Returns The job id generated by the Downloader.
18 19 20 |
# File 'lib/ferto/callback.rb', line 18 def job_id @job_id end |
#resource_url ⇒ String (readonly)
Returns The original resource URL of the job.
15 16 17 |
# File 'lib/ferto/callback.rb', line 15 def resource_url @resource_url end |
#response_code ⇒ Integer (readonly)
Returns The status code returned by the upstream server when the download was attempted.
22 23 24 |
# File 'lib/ferto/callback.rb', line 22 def response_code @response_code end |
Instance Method Details
#download_successful? ⇒ Boolean
Returns Whether the download job was successful.
68 69 70 |
# File 'lib/ferto/callback.rb', line 68 def download_successful? @success end |
#matching_url?(url) ⇒ Boolean
Determines whether the URL of the download is the same with the one the downloader used for the download.
58 59 60 |
# File 'lib/ferto/callback.rb', line 58 def matching_url?(url) resource_url == url end |
#mime_error? ⇒ Boolean
Return true if there is a Mime type mismatch.
63 64 65 |
# File 'lib/ferto/callback.rb', line 63 def mime_error? @mime_error end |