frizzle 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +151 -0
- data/Rakefile +10 -0
- data/frizzle.gemspec +30 -0
- data/lib/frizzle.rb +43 -0
- data/lib/frizzle/agencies.rb +32 -0
- data/lib/frizzle/arrival_estimates.rb +41 -0
- data/lib/frizzle/base.rb +58 -0
- data/lib/frizzle/exceptions.rb +8 -0
- data/lib/frizzle/routes.rb +25 -0
- data/lib/frizzle/segments.rb +32 -0
- data/lib/frizzle/stops.rb +23 -0
- data/lib/frizzle/vehicles.rb +41 -0
- data/lib/frizzle/version.rb +3 -0
- data/spec/fixtures/dish_cassettes/agencies.yml +214 -0
- data/spec/fixtures/dish_cassettes/agencies_find_options.yml +50 -0
- data/spec/fixtures/dish_cassettes/agencies_geo_default_radius.yml +54 -0
- data/spec/fixtures/dish_cassettes/agencies_geo_rectangle.yml +59 -0
- data/spec/fixtures/dish_cassettes/agencies_id_geo.yml +45 -0
- data/spec/fixtures/dish_cassettes/agency_geo_radius.yml +54 -0
- data/spec/fixtures/dish_cassettes/agency_id.yml +49 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_agencies.yml +1353 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_agencies_routes.yml +45 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_agencies_routes_stops.yml +45 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_agencies_stops.yml +45 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_find_options.yml +1444 -0
- data/spec/fixtures/dish_cassettes/routes_agencies.yml +846 -0
- data/spec/fixtures/dish_cassettes/routes_agencies_geo.yml +336 -0
- data/spec/fixtures/dish_cassettes/routes_find_options.yml +846 -0
- data/spec/fixtures/dish_cassettes/segments_agency_and_geo_area.yml +48 -0
- data/spec/fixtures/dish_cassettes/segments_agency_and_route.yml +64 -0
- data/spec/fixtures/dish_cassettes/segments_agency_id.yml +245 -0
- data/spec/fixtures/dish_cassettes/segments_find_options.yml +242 -0
- data/spec/fixtures/dish_cassettes/stops_agency_id.yml +3841 -0
- data/spec/fixtures/dish_cassettes/stops_find_options.yml +3841 -0
- data/spec/fixtures/dish_cassettes/vehicles_agencies.yml +760 -0
- data/spec/fixtures/dish_cassettes/vehicles_agencies_geo_area.yml +45 -0
- data/spec/fixtures/dish_cassettes/vehicles_agencies_routes.yml +82 -0
- data/spec/fixtures/dish_cassettes/vehicles_agencies_routes_geo_area.yml +45 -0
- data/spec/fixtures/dish_cassettes/vehicles_find_options.yml +845 -0
- data/spec/lib/frizzle/agencies_spec.rb +169 -0
- data/spec/lib/frizzle/arrival_estimates_spec.rb +97 -0
- data/spec/lib/frizzle/base_spec.rb +105 -0
- data/spec/lib/frizzle/exceptions_spec.rb +0 -0
- data/spec/lib/frizzle/routes_spec.rb +85 -0
- data/spec/lib/frizzle/segments_spec.rb +91 -0
- data/spec/lib/frizzle/stops_spec.rb +63 -0
- data/spec/lib/frizzle/vehicles_spec.rb +99 -0
- data/spec/lib/frizzle/version_spec.rb +9 -0
- data/spec/spec_helper.rb +18 -0
- metadata +244 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5c7035aef1e6d6cfd06387fd23c123cd89cb8fa1
|
4
|
+
data.tar.gz: e4bb1013ea4dc5e8abcb1a0b7fff2460326e4746
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 35467cf9d3843705c3daecf22e006a5c004d0db1e659d7ac36a2c93ec31e1a1166409e408136a530094c1555a1e852c3b3066e171b89c02b1febf6758ba986c9
|
7
|
+
data.tar.gz: 75b45a6e7737b4afeef4c19c22f0759fc40eaca1ee68ae000743b9e23463e1aac2b73d85689c559577ebef8f36f84d441760a59a05288f4582b5e5e0abe01586
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Tyler Pearson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
# Frizzle: A Ruby wrapper for the TransLoc API
|
2
|
+
|
3
|
+
Frizzle is a Ruby wrapper for the [TransLoc Public API](http://api.transloc.com/doc/).
|
4
|
+
|
5
|
+
Supports all the TransLoc v1.2 API methods. You can either use the whole API wrapper through `Frizzle` or use parts of it i.e. `Frizzle::Agencies.all` if you solely want to work with a particular resource.
|
6
|
+
|
7
|
+
For more information on the TransLoc API, visit [http://api.transloc.com/doc/](http://api.transloc.com/doc/).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'frizzle', :git => "git://github.com/tylerpearson/frizzle.git"
|
15
|
+
```
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem install "frizzle", :git => "git://github.com/tylerpearson/frizzle.git"
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
To start using the gem, you can either perform direct calls on `Frizzle`
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Frizzle.agencies.all
|
29
|
+
```
|
30
|
+
|
31
|
+
or through the corresponding class and class methods
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Frizzle::Agencies.all
|
35
|
+
```
|
36
|
+
|
37
|
+
The TransLoc API does not require an API key.
|
38
|
+
|
39
|
+
For methods that allow limiting the results with a geographical area filter, there are two form options: *rectangle form* and *point and radius form*.
|
40
|
+
|
41
|
+
To limit with *rectangle form*, pass two arrays ([lat, lng]) for the two geo area arguments. It would look like:
|
42
|
+
```ruby
|
43
|
+
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347], [35.78061,-78.68218])
|
44
|
+
```
|
45
|
+
|
46
|
+
To limit with *point and radius*, pass an array ([lat, lng]) to the first argument. The second argument is optional and can be used to pass a radius in meters of a circle around the point. If this is not filled out, it will default to 100.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347])
|
50
|
+
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347], 70)
|
51
|
+
```
|
52
|
+
|
53
|
+
### Agencies
|
54
|
+
|
55
|
+
Agencies can be accessed through `Frizzle.agencies` or `Frizzle::Agencies`. This API call can be requested every 10 seconds from the same IP address.
|
56
|
+
|
57
|
+
*Examples:*
|
58
|
+
```ruby
|
59
|
+
Frizzle::Agencies.all
|
60
|
+
Frizzle.agencies.all
|
61
|
+
Frizzle.agencies.find_by_id(168)
|
62
|
+
Frizzle.agencies.find_by_id([168,24])
|
63
|
+
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347], 75.5)
|
64
|
+
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347])
|
65
|
+
Frizzle.agencies.find_by_id_and_geo_area("168", [35.80176,-78.64347])
|
66
|
+
Frizzle.agencies.find_by_id_and_geo_area("168", [35.80176,-78.64347], 120)
|
67
|
+
Frizzle.agencies.find({:agencies => "12", :geo_area => "35.80176,-78.64347|100"})
|
68
|
+
```
|
69
|
+
|
70
|
+
### Segments
|
71
|
+
|
72
|
+
Segments can be accessed through `Frizzle.segments` or `Frizzle::Segments`. This API call can be requested every 10 seconds from the same IP address.
|
73
|
+
|
74
|
+
*Examples:*
|
75
|
+
```ruby
|
76
|
+
Frizzle::Segments.find_by_agencies(24)
|
77
|
+
Frizzle.segments.find_by_agencies(24)
|
78
|
+
Frizzle.segments.find_by_agencies(24)
|
79
|
+
Frizzle.segments.find_by_agencies([24,22])
|
80
|
+
Frizzle.segments.find_by_agencies_and_routes(24, [4000078, 4000383])
|
81
|
+
Frizzle.segments.find_by_agencies_and_geo_area(24, [35.98974,-78.90292])
|
82
|
+
Frizzle.segments.find_by_agencies_and_geo_area(24, [35.98974,-78.90292], 100)
|
83
|
+
Frizzle.segments.find({:agencies => "24"}
|
84
|
+
```
|
85
|
+
|
86
|
+
### Routes
|
87
|
+
|
88
|
+
Routes can be accessed through `Frizzle.routes` or `Frizzle::Routes`. This API call can be requested every 10 seconds from the same IP address.
|
89
|
+
|
90
|
+
*Examples:*
|
91
|
+
```ruby
|
92
|
+
Frizzle::Routes.find_by_agencies("24")
|
93
|
+
Frizzle.routes.find_by_agencies("24")
|
94
|
+
Frizzle.routes.find_by_agencies([24, 132])
|
95
|
+
Frizzle.routes.find_by_agencies_and_geo_area(24, [35.98974,-78.90292])
|
96
|
+
Frizzle::Routes.find({:agencies => "24"})
|
97
|
+
```
|
98
|
+
|
99
|
+
### Stops
|
100
|
+
|
101
|
+
Stops can be accessed through `Frizzle.stops` or `Frizzle::Stops`. This API call can be requested every 10 seconds from the same IP address.
|
102
|
+
|
103
|
+
*Examples:*
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
Frizzle::Stops.find_by_agencies(24)
|
107
|
+
Frizzle.stops.find_by_agencies(24)
|
108
|
+
Frizzle.stops.find_by_agencies_and_geo_area(24, [35.98974,-78.90292])
|
109
|
+
Frizzle::Stops.find({:agencies => "24"})
|
110
|
+
```
|
111
|
+
|
112
|
+
### Vehicles
|
113
|
+
|
114
|
+
Vehicles can be accessed through `Frizzle.vehicles` or `Frizzle::Vehicles`. This API call can be requested every 1 second from the same IP address.
|
115
|
+
|
116
|
+
*Examples:*
|
117
|
+
```ruby
|
118
|
+
Frizzle::Vehicles.find_by_agencies("24")
|
119
|
+
Frizzle.vehicles.find_by_agencies("24")
|
120
|
+
Frizzle.vehicles.find_by_agencies_and_routes("24", ["4003034","4003038"])
|
121
|
+
Frizzle.vehicles.find_by_agencies_and_routes_geo_area(24, ["4003034","4003038"], [35.98974,-78.90292])
|
122
|
+
Frizzle::Vehicles.find({:agencies => "24"})
|
123
|
+
```
|
124
|
+
|
125
|
+
### Arrival Estimates
|
126
|
+
|
127
|
+
Arrival estimates can be accessed through `Frizzle.arrival_estimates` or `Frizzle::ArrivalEstimates`. This API call can be requested every 1 second from the same IP address.
|
128
|
+
|
129
|
+
*Examples:*
|
130
|
+
```ruby
|
131
|
+
Frizzle::ArrivalEstimates.find_by_agencies("24")
|
132
|
+
Frizzle.arrival_estimates.find_by_agencies("24")
|
133
|
+
Frizzle.arrival_estimates.find_by_agencies_and_routes("24", ["4003034","4003038"])
|
134
|
+
Frizzle.arrival_estimates.find_by_agencies_and_stops("24", "1029")
|
135
|
+
Frizzle.arrival_estimates.find_by_agencies_and_routes_and_stops("24", ["4003034","4003038"], "1029")
|
136
|
+
Frizzle::ArrivalEstimates.find({:agencies => "24"})
|
137
|
+
```
|
138
|
+
|
139
|
+
## Contributing
|
140
|
+
|
141
|
+
This is my first Ruby gem, so any issues or pull requests with suggested improvements is appreciated.
|
142
|
+
|
143
|
+
1. Fork it
|
144
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
145
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
146
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
147
|
+
5. Create new Pull Request
|
148
|
+
|
149
|
+
## License
|
150
|
+
|
151
|
+
Copyright (c) 2013 Tyler Pearson. See LICENSE for details.
|
data/Rakefile
ADDED
data/frizzle.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'frizzle/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "frizzle"
|
8
|
+
spec.version = Frizzle::VERSION
|
9
|
+
spec.authors = ["Tyler Pearson"]
|
10
|
+
spec.email = ["ty.pearson@gmail.com"]
|
11
|
+
spec.description = %q{A wrapper for the TransLoc API}
|
12
|
+
spec.summary = %q{A wrapper for the TransLoc API}
|
13
|
+
spec.homepage = "https://github.com/tylerpearson/frizzle"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "webmock"
|
24
|
+
spec.add_development_dependency "vcr"
|
25
|
+
spec.add_development_dependency "turn"
|
26
|
+
spec.add_development_dependency "minitest"
|
27
|
+
|
28
|
+
spec.add_runtime_dependency "httparty"
|
29
|
+
spec.add_runtime_dependency "hashie"
|
30
|
+
end
|
data/lib/frizzle.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require 'singleton'
|
3
|
+
require 'hashie'
|
4
|
+
|
5
|
+
Hash.send :include, Hashie::Extensions::DeepMerge
|
6
|
+
|
7
|
+
require_relative 'frizzle/version'
|
8
|
+
require_relative 'frizzle/exceptions'
|
9
|
+
require_relative 'frizzle/base'
|
10
|
+
require_relative 'frizzle/agencies'
|
11
|
+
require_relative 'frizzle/segments'
|
12
|
+
require_relative 'frizzle/routes'
|
13
|
+
require_relative 'frizzle/stops'
|
14
|
+
require_relative 'frizzle/vehicles'
|
15
|
+
require_relative 'frizzle/arrival_estimates'
|
16
|
+
|
17
|
+
module Frizzle
|
18
|
+
|
19
|
+
def self.agencies
|
20
|
+
Frizzle::Agencies
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.segments
|
24
|
+
Frizzle::Segments
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.routes
|
28
|
+
Frizzle::Routes
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.stops
|
32
|
+
Frizzle::Stops
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.vehicles
|
36
|
+
Frizzle::Vehicles
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.arrival_estimates
|
40
|
+
Frizzle::ArrivalEstimates
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Frizzle
|
2
|
+
class Agencies < Base
|
3
|
+
|
4
|
+
def self.all
|
5
|
+
fetch("/agencies.json")
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find(options={})
|
9
|
+
fetch("/agencies.json",
|
10
|
+
:query => options )
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.find_by_id(agencies)
|
14
|
+
fetch("/agencies.json",
|
15
|
+
:query => { :agencies => formatted_list(agencies) })
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_by_geo_area(geo_area_first, geo_area_second=Frizzle::Base::DEFAULT_GEO_RADIUS)
|
19
|
+
fetch("/agencies.json",
|
20
|
+
:query => { :geo_area => formatted_geo_area(geo_area_first, geo_area_second) })
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.find_by_id_and_geo_area(agencies, geo_area_first, geo_area_second=Frizzle::Base::DEFAULT_GEO_RADIUS)
|
24
|
+
fetch("/agencies.json",
|
25
|
+
:query => {
|
26
|
+
:agencies => formatted_list(agencies),
|
27
|
+
:geo_area => formatted_geo_area(geo_area_first, geo_area_second)
|
28
|
+
})
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Frizzle
|
2
|
+
class ArrivalEstimates < Base
|
3
|
+
|
4
|
+
def self.find(options={})
|
5
|
+
fetch("/arrival-estimates.json",
|
6
|
+
:query => options )
|
7
|
+
end
|
8
|
+
|
9
|
+
# 168,275
|
10
|
+
def self.find_by_agencies(agencies)
|
11
|
+
fetch("/arrival-estimates.json",
|
12
|
+
:query => { :agencies => formatted_list(agencies) })
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.find_by_agencies_and_routes(agencies, routes)
|
16
|
+
fetch("/arrival-estimates.json",
|
17
|
+
:query => {
|
18
|
+
:agencies => formatted_list(agencies),
|
19
|
+
:routes => formatted_list(routes)
|
20
|
+
})
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.find_by_agencies_and_stops(agencies, stops)
|
24
|
+
fetch("/arrival-estimates.json",
|
25
|
+
:query => {
|
26
|
+
:agencies => formatted_list(agencies),
|
27
|
+
:stops => formatted_list(stops)
|
28
|
+
})
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.find_by_agencies_and_routes_and_stops(agencies, routes, stops)
|
32
|
+
fetch("/arrival-estimates.json",
|
33
|
+
:query => {
|
34
|
+
:agencies => formatted_list(agencies),
|
35
|
+
:routes => formatted_list(routes),
|
36
|
+
:stops => formatted_list(stops)
|
37
|
+
})
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
data/lib/frizzle/base.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Frizzle
|
2
|
+
class Base
|
3
|
+
include Singleton
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
API_VERSION = "1.2".freeze
|
7
|
+
DEFAULT_GEO_RADIUS = 100
|
8
|
+
|
9
|
+
base_uri "http://api.transloc.com/#{API_VERSION}"
|
10
|
+
|
11
|
+
def self.init_settings(options={})
|
12
|
+
{
|
13
|
+
:headers => {
|
14
|
+
"User-Agent" => "frizzle-ruby-#{Frizzle::VERSION}",
|
15
|
+
"Content-Type" => "application/json",
|
16
|
+
"Accept" => "application/json"
|
17
|
+
}
|
18
|
+
}.deep_merge(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.fetch(url, options = {})
|
22
|
+
options = self.init_settings(options)
|
23
|
+
response = get(url, options)
|
24
|
+
if response.success?
|
25
|
+
data = response.parsed_response['data']
|
26
|
+
elsif response.code == 403
|
27
|
+
raise "TransLoc API limit: #{response.response}"
|
28
|
+
else
|
29
|
+
raise TransLocAPIError.new, "#{response}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.is_numeric?(obj)
|
34
|
+
obj.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.formatted_list(list)
|
38
|
+
if list.instance_of? Array
|
39
|
+
list = list.join(',')
|
40
|
+
end
|
41
|
+
list.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
# Rectangle form: http://api.transloc.com/1.2/agencies.json?geo_area=35.80176,-78.64347|35.78061,-78.68218
|
45
|
+
# Point and radius form: http://api.transloc.com/1.2/agencies.json?geo_area=35.80176,-78.64347|75.5
|
46
|
+
def self.formatted_geo_area(first_geo, second_geo=DEFAULT_GEO_RADIUS)
|
47
|
+
if first_geo.instance_of?(Array) && second_geo.instance_of?(Array)
|
48
|
+
coordinates = "#{first_geo.join(',')}|#{second_geo.join(',')}"
|
49
|
+
elsif first_geo.instance_of?(Array) && is_numeric?(second_geo)
|
50
|
+
coordinates = "#{first_geo.join(',')}|#{second_geo}"
|
51
|
+
else
|
52
|
+
raise(ArgumentError, "Geo arguments do not match the required format")
|
53
|
+
end
|
54
|
+
"#{coordinates}"
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Frizzle
|
2
|
+
class Routes < Base
|
3
|
+
|
4
|
+
def self.find(options={})
|
5
|
+
fetch("/routes.json",
|
6
|
+
:query => options )
|
7
|
+
end
|
8
|
+
|
9
|
+
# 168,275
|
10
|
+
def self.find_by_agencies(agencies)
|
11
|
+
fetch("/routes.json",
|
12
|
+
:query => { :agencies => formatted_list(agencies) })
|
13
|
+
end
|
14
|
+
|
15
|
+
# 168 35.80176,-78.64347|75.5
|
16
|
+
def self.find_by_agencies_and_geo_area(agencies, geo_area_first, geo_area_second=Frizzle::Base::DEFAULT_GEO_RADIUS)
|
17
|
+
fetch("/routes.json",
|
18
|
+
:query => {
|
19
|
+
:agencies => formatted_list(agencies),
|
20
|
+
:geo_area => formatted_geo_area(geo_area_first, geo_area_second)
|
21
|
+
})
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|