parent
acd00004dc
commit
1f1ed4cc11
@ -0,0 +1,2 @@
|
||||
vendor
|
||||
enabled
|
@ -0,0 +1 @@
|
||||
2.0.0
|
@ -0,0 +1,5 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
group :development do
|
||||
gem 'pry'
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
coderay (1.1.1)
|
||||
method_source (0.8.2)
|
||||
pry (0.10.3)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
slop (3.6.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
pry
|
||||
|
||||
BUNDLED WITH
|
||||
1.11.2
|
@ -0,0 +1,5 @@
|
||||
desc ''
|
||||
task :bundle do
|
||||
cmd = 'bundle install --standalone --path vendor/bundle --without development test'
|
||||
sh "chruby-exec 2.0.0 -- #{cmd}"
|
||||
end
|
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'open-uri'
|
||||
require 'rexml/document'
|
||||
|
||||
COLOR_MAP = {
|
||||
arrivalStatusOnTime: :green,
|
||||
arrivalStatusNoInfo: :black,
|
||||
arrivalStatusEarly: :red,
|
||||
arrivalStatusDelayed: :blue,
|
||||
arrivalStatusDepartedOnTime: :green,
|
||||
arrivalStatusDepartedNoInfo: :black,
|
||||
arrivalStatusDepartedEarly: :red,
|
||||
arrivalStatusDepartedDelayed: :blue,
|
||||
arrivalStatusCancelled: :red,
|
||||
}
|
||||
|
||||
html = open('http://pugetsound.onebusaway.org/where/standard/stop.action?id=1_7360').read
|
||||
doc = REXML::Document.new(html)
|
||||
status = doc.elements['//td[contains(@class, "arrivalsStatusEntry")]']
|
||||
|
||||
minutes = status.elements['//span'].text
|
||||
color = COLOR_MAP[status.attributes['class'].split(/\s+/).last.to_sym]
|
||||
times = doc.elements.to_a('//div[@class="arrivalsTimePanel"]')
|
||||
|
||||
puts "#{minutes} | color=#{color}"
|
||||
puts '---'
|
||||
times.each do |time|
|
||||
puts "#{time[0].text}#{time[1]}#{time[2].text}"
|
||||
end
|
Loading…
Reference in new issue