Class: DiffbotSimple::V2::Crawl
- Inherits:
-
Object
- Object
- DiffbotSimple::V2::Crawl
show all
- Defined in:
- lib/diffbot_simple/v2/crawl.rb
Direct Known Subclasses
Bulk
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(crawlbot_api: nil, name: nil, init: {}, **parameters) ⇒ Crawl
Returns a new instance of Crawl.
4
5
6
7
8
9
10
11
12
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 4
def initialize crawlbot_api: nil, name: nil, init: {}, **parameters
@crawlbot_api = crawlbot_api
@name = name
if init.empty?
send_to_api parameters
else
@parameters = init
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(property, *args) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 38
def method_missing property, *args
key = property.to_s.gsub(/\=$/,"").to_sym
super unless parameters.has_key? key
return send_to_api({ key => args.join(",") }) if property.to_s.match(/\=$/) or !args.empty?
return parameters[key]
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3
4
5
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 3
def name
@name
end
|
#parameters ⇒ Object
Returns the value of attribute parameters.
3
4
5
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 3
def parameters
@parameters
end
|
Instance Method Details
#apiUrl=(api_url) ⇒ Object
35
36
37
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 35
def apiUrl= api_url
send_to_api apiUrl: api_url
end
|
#delete! ⇒ Object
19
20
21
22
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 19
def delete!
send_to_api delete: 1
@parameters = {}
end
|
#pause ⇒ Object
13
14
15
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 13
def pause
send_to_api pause: 1
end
|
#refresh ⇒ Object
32
33
34
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 32
def refresh
send_to_api
end
|
#restart ⇒ Object
23
24
25
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 23
def restart
send_to_api restart: 1
end
|
#results ⇒ Object
29
30
31
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 29
def results
crawlbot_api.results url: parameters[:downloadJson]
end
|
#unpause ⇒ Object
16
17
18
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 16
def unpause
send_to_api pause: 0
end
|
#update(**parameters) ⇒ Object
26
27
28
|
# File 'lib/diffbot_simple/v2/crawl.rb', line 26
def update **parameters
send_to_api parameters
end
|