Class: MediawikiRobot::Robot
- Inherits:
-
Object
- Object
- MediawikiRobot::Robot
- Defined in:
- lib/mediawiki_robot/robot.rb
Constant Summary collapse
- API_SUFFIX =
'/api.php'
- MAX_SIMULTANEOUS_THREADS =
10
Instance Attribute Summary collapse
-
#mw ⇒ Object
Returns the value of attribute mw.
Instance Method Summary collapse
-
#initialize(mw_opts) ⇒ Robot
constructor
A new instance of Robot.
- #is_running ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(mw_opts) ⇒ Robot
Returns a new instance of Robot.
16 17 18 19 20 21 22 23 |
# File 'lib/mediawiki_robot/robot.rb', line 16 def initialize(mw_opts) api_url = mw_opts[:base_url] + mw_opts[:normal_prefix] + API_SUFFIX @mw = MediawikiRobot::EnhancedGateway.new(api_url, {:ignorewarnings=>1}) @thread = nil @mainloop_sleep_secs = 5.0 # make this non-constant so that it can be overridden for testing end |
Instance Attribute Details
#mw ⇒ Object
Returns the value of attribute mw.
11 12 13 |
# File 'lib/mediawiki_robot/robot.rb', line 11 def mw @mw end |
Instance Method Details
#is_running ⇒ Object
33 34 35 36 37 |
# File 'lib/mediawiki_robot/robot.rb', line 33 def is_running return false if @thread.nil? return true unless @thread.status.nil? or @thread.status == false return false end |
#start ⇒ Object
25 26 27 |
# File 'lib/mediawiki_robot/robot.rb', line 25 def start @thread = Thread.new { main_loop } end |
#stop ⇒ Object
29 30 31 |
# File 'lib/mediawiki_robot/robot.rb', line 29 def stop @thread.kill end |