ratis 3.3.4 → 3.3.5

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.
data/CHANGELOG CHANGED
@@ -31,4 +31,7 @@
31
31
  - When querying Nextbus for a Light Rail stop, in most cases you will actually get back 2 stops for a single NextRide ID. One for each side of the stop platform. Made changes to handle this case. Both stops services are flattened into the #services attribute.
32
32
 
33
33
  3.2.1
34
- - Timetable::Trip now contains the trip's headsign
34
+ - Timetable::Trip now contains the trip's headsign
35
+
36
+ 3.3.5
37
+ - Refactored Ratis::Location to be usable in Trip Planner
@@ -2,7 +2,27 @@ module Ratis
2
2
 
3
3
  class Location
4
4
 
5
- attr_accessor :name, :area, :response, :areacode, :latitude, :longitude, :landmark_id, :address, :startaddr, :endaddr, :address_string
5
+ attr_accessor :name, :area, :areacode, :region, :zipname, :latitude, :longitude, :address, :landmark_id,
6
+ :responsecode, :startaddr, :endaddr, :startlatitude, :startlongitude, :endlatitude, :endlongitude
7
+
8
+ def initialize(params)
9
+ @name = params[:name]
10
+ @area = params[:area]
11
+ @areacode = params[:areacode]
12
+ @region = params[:region]
13
+ @zipname = params[:zipname]
14
+ @latitude = params[:latitude]
15
+ @longitude = params[:longitude]
16
+ @address = params[:address] || ''
17
+ @landmark_id = params[:landmarkid] || 0
18
+ @responsecode = params[:responsecode]
19
+ @startaddr = params[:startaddr]
20
+ @endaddr = params[:endaddr]
21
+ @startlatitude = params[:startlatitude]
22
+ @startlongitude = params[:startlongitude]
23
+ @endlatitude = params[:endlatitude]
24
+ @endlongitude = params[:endlongitude]
25
+ end
6
26
 
7
27
  def self.where(conditions)
8
28
  location = conditions.delete :location
@@ -17,32 +37,22 @@ module Ratis
17
37
  raise ArgumentError.new('You must provide a numeric max_answers') unless (Integer max_answers rescue false)
18
38
  Ratis.all_conditions_used? conditions
19
39
 
20
- response = Request.get 'Locate', {'Appid' => app_id,
21
- 'Location' => location,
22
- 'Area' => area,
23
- 'Region' => region,
40
+ response = Request.get 'Locate', {'Appid' => app_id,
41
+ 'Location' => location,
42
+ 'Area' => area,
43
+ 'Region' => region,
24
44
  'Maxanswers' => max_answers,
25
- 'Media' => media }
45
+ 'Media' => media }
26
46
  return [] unless response.success?
27
47
 
28
- meta = response.to_hash[:locate_response]
29
- locations = response.to_array :locate_response, :location
48
+ response_code = response.to_hash[:locate_response][:responsecode]
49
+ locations = response.to_array :locate_response, :location
30
50
 
51
+ # {:name=>"N 1ST AVE", :area=>"Avondale", :areacode=>"AV", :region=>"1", :zipname=>"85323 - Avondale", :latitude=>"33.436246", :longitude=>"-112.350520", :address=>"101", :landmarkid=>"0"}
31
52
  locations.map do |location_hash|
32
- location = Ratis::Location.new
33
- location.name = location_hash[:name]
34
- location.area = location_hash[:area]
35
- location.response = meta[:responsecode]
36
- location.areacode = location_hash[:areacode]
37
- location.latitude = location_hash[:latitude]
38
- location.longitude = location_hash[:longitude]
39
- location.landmark_id = location_hash[:landmarkid] || 0
40
- location.address = location_hash[:address] || ''
41
- location.startaddr = location_hash[:startaddr] || ''
42
- location.endaddr = location_hash[:endaddr] || ''
43
- location.address_string = build_address_string location_hash
44
- location
53
+ Ratis::Location.new(location_hash.merge(responsecode: response_code))
45
54
  end
55
+
46
56
  end
47
57
 
48
58
  def to_a
@@ -54,25 +64,21 @@ module Ratis
54
64
  Hash[keys.map { |k| [k, send(k)] }]
55
65
  end
56
66
 
57
- private
67
+ def address_string
68
+ full_address
69
+ end
58
70
 
59
- def self.build_address_string(location_hash)
60
- address_string = ''
61
- address = location_hash[:address]
62
- name = location_hash[:name]
63
- area = location_hash[:area]
71
+ def full_address
72
+ temp = ""
64
73
 
65
- if !address.blank?
66
- address_string << "#{address} #{name} (in #{area})"
74
+ if address.present?
75
+ temp << "#{address} #{name} (in #{area})"
76
+ elsif startaddr.present?
77
+ temp << "#{startaddr} - #{endaddr} #{name} (in #{area})"
67
78
  else
68
- startaddr = location_hash[:startaddr]
69
- if !startaddr.blank?
70
- endaddr = location_hash[:endaddr]
71
- address_string << "#{startaddr} - #{endaddr} #{name} (in #{area})"
72
- else
73
- address_string << "#{name} (in #{area})"
74
- end
79
+ temp << "#{name} (in #{area})"
75
80
  end
81
+
76
82
  end
77
83
  end
78
84
 
@@ -5,7 +5,7 @@ module Ratis
5
5
  def version
6
6
  @version ||= begin
7
7
 
8
- string = '3.3.4'
8
+ string = '3.3.5'
9
9
 
10
10
  def string.parts
11
11
  split('.').map { |p| p.to_i }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 3
9
- - 4
10
- version: 3.3.4
9
+ - 5
10
+ version: 3.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Burst Software
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-12-06 00:00:00 Z
18
+ date: 2013-12-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon