Class: Watchman::MedicWatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/watchman/medic_watcher.rb

Constant Summary collapse

STATUSI =
["AVL","DSP","ENR","TRN","ARV","AV1","INC","OFF","ONS","ORP","ENH","ONH","AOS","OOD","OOS","AAS"]

Instance Method Summary collapse

Constructor Details

#initializeMedicWatcher

Returns a new instance of MedicWatcher.



5
6
7
# File 'lib/watchman/medic_watcher.rb', line 5

def initialize
  @client = Client.new
end

Instance Method Details

#city_statusObject



21
22
23
# File 'lib/watchman/medic_watcher.rb', line 21

def city_status
  count(/TruckID=M(11|15|21|22|23)\d/,"AVL")
end

#county_statusObject



25
26
27
# File 'lib/watchman/medic_watcher.rb', line 25

def county_status
  count(/TruckID=M(11|13|15|21|22|23|24)\d/,"AVL")
end

#pageObject



13
14
15
16
17
18
19
# File 'lib/watchman/medic_watcher.rb', line 13

def page
  if @_medic_page.nil?
    @client.add_cookie(cookie,"TScreen")
    @_medic_page = @client.get("AjaxTS2.php")
  end
  @_medic_page
end

#raw_pageObject



9
10
11
# File 'lib/watchman/medic_watcher.rb', line 9

def raw_page
  page.parser.to_s
end

#status_of(medic) ⇒ Object



29
30
31
32
33
34
# File 'lib/watchman/medic_watcher.rb', line 29

def status_of(medic)
  STATUSI.each do |status|
    return status if count(/TruckID=M#{medic}/,status) >= 1
  end
  "OOS"
end