class MTAStatus
Constants
- LIRR
- METRO_NORTH
Attributes
doc[RW]
Public Class Methods
new(service)
click to toggle source
# File lib/mta_status.rb, line 10 def initialize(service) @service = service.downcase if service @doc = Nokogiri::HTML(open(MTA)) run end
Public Instance Methods
lirr()
click to toggle source
# File lib/mta_status.rb, line 42 def lirr output[30..40] end
metro_north()
click to toggle source
# File lib/mta_status.rb, line 46 def metro_north output[41..50] end
name()
click to toggle source
# File lib/mta_status.rb, line 16 def name @doc.xpath("//name").collect do |name| name.children.text end end
note()
click to toggle source
# File lib/mta_status.rb, line 28 def note @doc.xpath("//text").collect do |note| note.children.text end end
output()
click to toggle source
# File lib/mta_status.rb, line 34 def output name.zip(status) end
run()
click to toggle source
# File lib/mta_status.rb, line 60 def run puts puts "##### Train Status ######" puts Time.now puts "#########################" service_choice.each do |line_pair| if line_pair[1]!="GOOD SERVICE" puts "#{line_pair[0].bold}: #{line_pair[1].red}" else puts "#{line_pair[0]}: #{line_pair[1].green}" end end puts "#########################" end
service_choice()
click to toggle source
# File lib/mta_status.rb, line 50 def service_choice if LIRR.include?(@service) lirr elsif METRO_NORTH.include?(@service) metro_north else subway end end
status()
click to toggle source
# File lib/mta_status.rb, line 22 def status @doc.xpath("//status").collect do |s| s.children.text end end
subway()
click to toggle source
# File lib/mta_status.rb, line 38 def subway output[0..10] end