Class: SpiderGazelle::Gazelle
- Inherits:
-
Object
- Object
- SpiderGazelle::Gazelle
- Defined in:
- lib/spider-gazelle/gazelle.rb,
lib/spider-gazelle/gazelle/request.rb
Defined Under Namespace
Classes: Request
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize(thread, type) ⇒ Gazelle
constructor
A new instance of Gazelle.
- #run!(options) ⇒ Object
- #shutdown(defer) ⇒ Object
Constructor Details
#initialize(thread, type) ⇒ Gazelle
Returns a new instance of Gazelle.
12 13 14 15 16 17 18 19 |
# File 'lib/spider-gazelle/gazelle.rb', line 12 def initialize(thread, type) raise ArgumentError, "type must be one of #{MODES}" unless MODES.include?(type) @type = type @logger = Logger.instance @thread = thread @thread.ref end |
Instance Attribute Details
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
22 23 24 |
# File 'lib/spider-gazelle/gazelle.rb', line 22 def thread @thread end |
Instance Method Details
#run!(options) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/spider-gazelle/gazelle.rb', line 25 def run!() @options = @logger.verbose { "Gazelle: #{@type} started" } self end |
#shutdown(defer) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/spider-gazelle/gazelle.rb', line 32 def shutdown(defer) @thread.schedule do # TODO:: Wait for the requests to finish @thread.unref @logger.verbose { "Gazelle: #{@type} shutting down" } @thread.stop defer.resolve(true) end end |