Class: PIT::Busomatic
Constant Summary collapse
- @@key =
nil
Class Method Summary collapse
- .bulletins(options = {}) ⇒ Object
- .directions(options = {}) ⇒ Object
- .key=(key) ⇒ Object
- .patterns(options = {}) ⇒ Object
- .predictions(options = {}) ⇒ Object
- .routes(options = {}) ⇒ Object
- .stops(options = {}) ⇒ Object
- .time(options = {}) ⇒ Object
- .vehicles(options = {}) ⇒ Object
Class Method Details
.bulletins(options = {}) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/bus-o-matic.rb', line 109 def self.bulletins(={}) .merge!({ :key => @@key }) [:rt] = [:rt].join(',') if [:rt].kind_of?(Array) [:stpid] = [:stpid].join(',') if [:stpid].kind_of?(Array) response = get("/getservicebulletins", :query => )['bustime_response'] check_for_errors response['error'] results = Array.wrap response['sb'] results.map { |result| Hashie::Mash.new result } unless results.nil? end |
.directions(options = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bus-o-matic.rb', line 59 def self.directions(={}) .merge!({ :key => @@key }) response = get("/getdirections", :query => )['bustime_response'] check_for_errors response['error'] results = Array.wrap response['dir'] results.map { |direction| direction.split(/ /)[0] } unless results.nil? end |
.key=(key) ⇒ Object
123 124 125 |
# File 'lib/bus-o-matic.rb', line 123 def self.key=(key) @@key = key end |
.patterns(options = {}) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/bus-o-matic.rb', line 81 def self.patterns(={}) .merge!({ :key => @@key }) [:pid] = [:pid].join(',') if [:pid].kind_of?(Array) response = get("/getpatterns", :query => )['bustime_response'] check_for_errors response['error'] results = Array.wrap response['ptr'] results.map { |result| Hashie::Mash.new result } unless results.nil? end |
.predictions(options = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/bus-o-matic.rb', line 94 def self.predictions(={}) .merge!({ :key => @@key }) [:stpid] = [:stpid].join(',') if [:stpid].kind_of?(Array) [:rt] = [:rt].join(',') if [:rt].kind_of?(Array) [:vid] = [:vid].join(',') if [:vid].kind_of?(Array) response = get("/getpredictions", :query => )['bustime_response'] check_for_errors response['error'] results = Array.wrap response['prd'] results.map { |result| Hashie::Mash.new result } unless results.nil? end |
.routes(options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bus-o-matic.rb', line 48 def self.routes(={}) .merge!({ :key => @@key }) response = get("/getroutes", :query => )['bustime_response'] check_for_errors response['error'] results = Array.wrap response['route'] Hash[ results.map { |result| [result['rt'], result['rtnm']] } ] unless results.nil? end |
.stops(options = {}) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bus-o-matic.rb', line 70 def self.stops(={}) .merge!({ :key => @@key }) response = get("/getstops", :query => )['bustime_response'] check_for_errors response['error'] results = Array.wrap response['stop'] results.map { |result| Hashie::Mash.new result } unless results.nil? end |
.time(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/bus-o-matic.rb', line 24 def self.time(={}) .merge!({ :key => @@key }) response = get("/gettime", :query => )['bustime_response'] check_for_errors response['error'] Time.parse response['tm'] end |
.vehicles(options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bus-o-matic.rb', line 34 def self.vehicles(={}) .merge!({ :key => @@key }) [:vid] = [:vid].join(',') if [:vid].kind_of?(Array) [:rt] = [:rt].join(',') if [:rt].kind_of?(Array) response = get("/getvehicles", :query => )['bustime_response'] check_for_errors response['error'] results = Array.wrap response['vehicle'] results.map { |result| Hashie::Mash.new result } unless results.nil? end |