Class: Webpipe::CrawlJob
- Inherits:
-
Object
- Object
- Webpipe::CrawlJob
- Defined in:
- lib/webpipe/types.rb
Overview
Status and (partial or final) results of a crawl job.
Results expire 24h after completion (see expires_at).
Constant Summary collapse
- STATUS_SCRAPING =
"scraping"- STATUS_COMPLETED =
"completed"- STATUS_FAILED =
"failed"
Instance Attribute Summary collapse
-
#completed ⇒ Object
readonly
Returns the value of attribute completed.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status:, total: 0, completed: 0, data: [], errors: [], expires_at: nil) ⇒ CrawlJob
constructor
A new instance of CrawlJob.
Constructor Details
#initialize(status:, total: 0, completed: 0, data: [], errors: [], expires_at: nil) ⇒ CrawlJob
Returns a new instance of CrawlJob.
57 58 59 60 61 62 63 64 |
# File 'lib/webpipe/types.rb', line 57 def initialize(status:, total: 0, completed: 0, data: [], errors: [], expires_at: nil) @status = status @total = total @completed = completed @data = data @errors = errors @expires_at = expires_at end |
Instance Attribute Details
#completed ⇒ Object (readonly)
Returns the value of attribute completed.
55 56 57 |
# File 'lib/webpipe/types.rb', line 55 def completed @completed end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
55 56 57 |
# File 'lib/webpipe/types.rb', line 55 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
55 56 57 |
# File 'lib/webpipe/types.rb', line 55 def errors @errors end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
55 56 57 |
# File 'lib/webpipe/types.rb', line 55 def expires_at @expires_at end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
55 56 57 |
# File 'lib/webpipe/types.rb', line 55 def status @status end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
55 56 57 |
# File 'lib/webpipe/types.rb', line 55 def total @total end |
Class Method Details
.from_hash(hash) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/webpipe/types.rb', line 66 def self.from_hash(hash) new( status: hash["status"], total: hash["total"] || 0, completed: hash["completed"] || 0, data: (hash["data"] || []).map { |d| Document.from_hash(d) }, errors: hash["errors"] || [], expires_at: hash["expires_at"] ) end |