rome2rio 0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03ec9441a72831df297c2ac4281c433169c7d08e
4
- data.tar.gz: 9629577e4d586cbd3522ab82dcd7216903418063
3
+ metadata.gz: 5af31728b88661d755bb1d912250582e62ca27a5
4
+ data.tar.gz: d10f70d72683309085562eb9e8678d0516566d53
5
5
  SHA512:
6
- metadata.gz: 8b34778ea682a760038375d3e3d5929eede320dcac96d1bd73a04ce7f7cdccd28942e2f63e765799c0f9959a0699e4ddc73cda79ddbb4e9f1912ee1aa54acb34
7
- data.tar.gz: f97f41bd12a419cb0cdbde70f993fc4f5bc9da8c9513857e49cf2f5c874653af9d445e07361fa14ad1c0447f27b9fd0d5ba999d057c9bd3e4465eae49c59518b
6
+ metadata.gz: 7c6b1818a457d1ccbe34516f38e9d4e7e8f970dd27463f7cc70c22738d0dc6dd748a49f72201c01a4f51c9354bfbf856f94766eae3f1867bea077498977e1fef
7
+ data.tar.gz: c6dbea3006eb013c6b55e40f586afb897f51108bb1b9ebead9d2d92691673121b7541db920f78a49f0f2bc60ef0b80dbb7039883fb102c7d9097ec3536b64e32
data/README.md CHANGED
@@ -14,7 +14,7 @@ gem install rome2rio
14
14
  Usage
15
15
  -----
16
16
 
17
- ```
17
+ ```ruby
18
18
  require 'rome2rio'
19
19
  results = Rome2rio::Connection.new.search(search options)
20
20
  puts results.routes[0].duration
@@ -28,7 +28,7 @@ Complex datatypes (such as Position, Size, Offset, DayFlags) will be parsed.
28
28
 
29
29
  Using Position for input:
30
30
 
31
- ```
31
+ ```ruby
32
32
  Rome2rio::Connection.new.search({:oPos => Rome2rio::Position.new(41.79443,12.25108), :dPos => Rome2rio::Position.new(-22.81215,-43.24721)})
33
33
  ```
34
34
 
@@ -2,7 +2,7 @@ module Rome2rio
2
2
  class Connection
3
3
  def initialize(opts = {})
4
4
  @apikey = opts[:apikey]
5
- @endpoint = opts[:endpoint] || "http://evaluate.rome2rio.com"
5
+ @endpoint = opts[:endpoint] || "http://free.rome2rio.com"
6
6
  end
7
7
 
8
8
  def handle_response(response)
@@ -0,0 +1,10 @@
1
+ module Rome2rio
2
+ class Aircraft
3
+ attr_reader :code, :manufacturer, :model
4
+ def initialize(json)
5
+ @code = json["code"]
6
+ @manufacturer = json["manufacturer"]
7
+ @model = json["model"]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Rome2rio
2
+ class Codeshare
3
+ attr_reader :airline
4
+ def initialize(json)
5
+ @airline = json["airline"]
6
+ end
7
+ end
8
+ end
@@ -1,18 +1,25 @@
1
1
  module Rome2rio
2
2
  class FlightHop
3
- attr_reader :sCode, :tCode, :sTime, :tTime, :airline, :flight,
4
- :duration, :dayChange, :lDuration, :lDayChange
3
+ attr_reader :sCode, :tCode, :sTerminal, :tTerminal,
4
+ :sTime, :tTime, :airline, :flight, :duration,
5
+ :aircraft, :dayChange, :lDuration, :lDayChange,
6
+ :codeshares
5
7
  def initialize(json)
6
8
  @sCode = json["sCode"]
7
9
  @tCode = json["tCode"]
10
+ @sTerminal = json["sTerminal"]
11
+ @tTerminal = json["tTerminal"]
8
12
  @sTime = json["sTime"]
9
13
  @tTime = json["tTime"]
10
14
  @airline = json["airline"]
11
15
  @flight = json["flight"]
12
16
  @duration = json["duration"]
17
+ @aircraft = json["aircraft"]
13
18
  @dayChange = json["dayChange"] if json["dayChange"]
14
19
  @lDuration = json["lDuration"] if json["lDuration"]
15
20
  @lDayChange = json["lDayChange"] if json["lDayChange"]
21
+ @codeshares = []
22
+ json["codeshares"].each { |codeshare| @codeshares << Codeshare.new(codeshare) }
16
23
  end
17
24
  end
18
25
  end
@@ -1,6 +1,6 @@
1
1
  module Rome2rio
2
2
  class SearchResponse
3
- attr_reader :agencies, :airlines, :airports, :routes, :verbatim
3
+ attr_reader :agencies, :airlines, :airports, :aircrafts, :routes, :verbatim, :data
4
4
  def initialize(json)
5
5
  @verbatim = json
6
6
 
@@ -10,11 +10,16 @@ module Rome2rio
10
10
  @airlines = []
11
11
  json["airlines"].each { |airline| @airlines << Airline.new(airline) }
12
12
 
13
+ @aircrafts = []
14
+ json["aircrafts"].each { |aircraft| @aircrafts << Aircraft.new(aircraft) }
15
+
13
16
  @airports = []
14
17
  json["airports"].each { |airport| @airports << Airport.new(airport) }
15
18
 
16
19
  @routes = []
17
20
  json["routes"].each { |route| @routes << Route.new(route) }
21
+
22
+ @data = json["data"]
18
23
  end
19
24
  end
20
25
  end
@@ -1,17 +1,17 @@
1
1
  module Rome2rio
2
2
  class Segment
3
3
  attr_reader :kind, :isMajor, :distance, :duration, :indicativePrice, :isImperial,
4
- :sName, :sPos, :sCode, :tName, :tPos, :tCode, :path, :itineraries
4
+ :sName, :sPos, :sCode, :tName, :tPos, :tCode, :path, :itineraries, :subkind
5
5
  def initialize(json)
6
6
  # Possible kinds: walk, car, train, bus, ferry, flight
7
7
  @kind = json["kind"]
8
- @isMajor = json["isMajor"]
8
+ @isMajor = json["isMajor"] == 1
9
9
  @distance = json["distance"]
10
10
  @duration = json["duration"]
11
11
  @indicativePrice = IndicativePrice.new(json["indicativePrice"])
12
12
 
13
13
  if @kind != "flight" then
14
- @isImperial = json["isImperial"]
14
+ @isImperial = json["isImperial"] == 1
15
15
  @sName = json["sName"]
16
16
  @sPos = Position.parse(json["sPos"])
17
17
  @tName = json["tName"]
@@ -25,6 +25,7 @@ module Rome2rio
25
25
  end
26
26
 
27
27
  if [ "train", "bus", "ferry" ].include?(@kind) then
28
+ @subkind = json["subkind"]
28
29
  @itineraries = []
29
30
  json["itineraries"].each { |itinerary| @itineraries << TransitItinerary.new(itinerary) }
30
31
  end
@@ -2,12 +2,13 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "rome2rio"
5
- gem.version = "0.1"
5
+ gem.version = "0.2.0"
6
6
  gem.authors = ["Alex Beregszaszi"]
7
7
  gem.email = ["alex@rtfs.hu"]
8
8
  gem.description = "A Ruby wrapper for the Rome2rio API. See http://www.rome2rio.com/documentation/search for the official documentation."
9
9
  gem.summary = "A Ruby wrapper for the Rome2rio API."
10
10
  gem.homepage = "http://github.com/axic/rome2rio"
11
+ gem.license = "MIT"
11
12
 
12
13
  gem.add_dependency 'faraday'
13
14
  gem.add_dependency 'multi_json'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rome2rio
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Beregszaszi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-28 00:00:00.000000000 Z
11
+ date: 2014-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -61,8 +61,10 @@ files:
61
61
  - lib/rome2rio/helper/search_request_flags.rb
62
62
  - lib/rome2rio/helper/size.rb
63
63
  - lib/rome2rio/response/agency.rb
64
+ - lib/rome2rio/response/aircraft.rb
64
65
  - lib/rome2rio/response/airline.rb
65
66
  - lib/rome2rio/response/airport.rb
67
+ - lib/rome2rio/response/codeshare.rb
66
68
  - lib/rome2rio/response/flight_hop.rb
67
69
  - lib/rome2rio/response/flight_itinerary.rb
68
70
  - lib/rome2rio/response/flight_leg.rb
@@ -77,7 +79,8 @@ files:
77
79
  - lib/rome2rio/response/transit_line.rb
78
80
  - rome2rio.gemspec
79
81
  homepage: http://github.com/axic/rome2rio
80
- licenses: []
82
+ licenses:
83
+ - MIT
81
84
  metadata: {}
82
85
  post_install_message:
83
86
  rdoc_options: []