Class: ScoutAgent::Order::CheckInOrder
- Inherits:
-
ScoutAgent::Order
- Object
- ScoutAgent::Order
- ScoutAgent::Order::CheckInOrder
- Defined in:
- lib/scout_agent/order/check_in_order.rb
Overview
This type of Order can be used to request a check-in over the XMPP interface. Times can also be cleared for the desired missions to ensure they’re included in the check-in.
Constant Summary collapse
- MATCH_RE =
The pattern of supported commands:
checkin checkin 1 checkin 1 2 3 check-in check-in 1 check-in 1 2 3 check_in check_in 1 check_in 1 2 3
/\A\s*check[-_]?in(?:\s+(.+?))?\s*\z/
Constants inherited from ScoutAgent::Order
Instance Attribute Summary
Attributes inherited from ScoutAgent::Order
Class Method Summary collapse
-
.mission_log ⇒ Object
Returns the mission log database or exit()‘s with an error if it cannot be loaded.
Instance Method Summary collapse
-
#execute ⇒ Object
Requests a check-in by waking up the master agent.
Methods inherited from ScoutAgent::Order
can_handle?, inherited, #initialize, load_all, log, #log, log=, master_agent, match?, #notify_master, subclasses
Constructor Details
This class inherits a constructor from ScoutAgent::Order
Class Method Details
.mission_log ⇒ Object
Returns the mission log database or exit()‘s with an error if it cannot be loaded.
31 32 33 34 35 36 37 38 |
# File 'lib/scout_agent/order/check_in_order.rb', line 31 def self.mission_log return @mission_log if defined? @mission_log unless db = Database.load(:mission_log, log) log.fatal("Could not load mission log database.") exit(1) end @mission_log = db end |
Instance Method Details
#execute ⇒ Object
Requests a check-in by waking up the master agent. All provided mission ID’s will have their run times reset before the check-in requested.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/scout_agent/order/check_in_order.rb', line 44 def execute if id_str = match_details.captures.first ids = id_str.scan(/\d+/).map { |n| n.to_i } unless ids.empty? s = ids.size == 1 ? "" : "s" ids_str = case ids.size when 1 then ids.first.to_s when 2 then ids.join(" and ") else ids[0..-2].join(", ") + ", and #{ids.last}" end log.info("Clearing wait time#{s} for mission#{s} (#{ids_str}).") self.class.mission_log.reset_missions(*ids) end end log.info("Requesting an immediate check-in.") notify_master end |