Skip to content

Commit

Permalink
Added support for the /AccidentStats and /AirQuality resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeHackett committed Feb 16, 2017
1 parent 45617e4 commit 9d845b7
Show file tree
Hide file tree
Showing 34 changed files with 140,842 additions and 8,351 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## v0.3.0 [16-FEB-2017]
* Added support for the /AccidentStats resource.
* Added support for the /AirQuality resource.


## v0.2.1 [14-FEB-2017]
* Updated project dependencies to latest versions.
* Added Ruby 2.4.0 to travis build.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 - 2016 Luke Hackett
Copyright (c) 2015 - 2017 Luke Hackett

MIT License

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ and [Factory Girl][factory_girl].

## License

Copyright (c) 2015 - 2016 Luke Hackett. MIT Licensed, see [LICENSE][license] for details.
Copyright (c) 2015 - 2017 Luke Hackett. MIT Licensed, see [LICENSE][license] for details.

[license]: LICENSE

2 changes: 2 additions & 0 deletions lib/tfl_api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

require 'tfl_api_client/version'
require 'tfl_api_client/client'
require 'tfl_api_client/accident_stats'
require 'tfl_api_client/air_quality'
require 'tfl_api_client/bike_point'
require 'tfl_api_client/cycle'
require 'tfl_api_client/exceptions'
Expand Down
55 changes: 55 additions & 0 deletions lib/tfl_api_client/accident_stats.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright (c) 2015 - 2017 Luke Hackett
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

module TflApi
class Client
# This class communicates with the TFL "/AccidentStats" API to obtain
# details about Accident Statistics based upon the year the accident
# occurred.
#
class AccidentStats

# Initialize the AccidentStats object and store the reference to Client
# object.
#
# @param client [Client] the client object
#
# @return [AccidentStats] the AccidentStats object
#
def initialize(client)
@client = client
end

# Returns all accident details for accidents occurring in the specified
# year.
#
# @return [Array] An array of hashes containing all Accident Statistics
#
def details(year)
@client.get("/AccidentStats/#{year}")
end
end
end
end
54 changes: 54 additions & 0 deletions lib/tfl_api_client/air_quality.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Copyright (c) 2015 - 2017 Luke Hackett
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

module TflApi
class Client
# This class communicates with the TFL "/AirQuality" API to obtain
# details about London's Air Quality.
#
class AirQuality

# Initialize the AirQuality object and store the reference to Client
# object.
#
# @param client [Client] the client object
#
# @return [AirQuality] the AirQuality object
#
def initialize(client)
@client = client
end

# Returns all Air Quality details for the current time period (currently
# every hour).
#
# @return [Hash] A hash containing details upon London's Air Quality
#
def details
@client.get('/AirQuality')
end
end
end
end
1 change: 0 additions & 1 deletion lib/tfl_api_client/bike_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#


module TflApi
class Client
# This class communicates with the TFL "/BikePoint" API to obtain details
Expand Down
16 changes: 16 additions & 0 deletions lib/tfl_api_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ def initialize(args)
end
end

# Creates an instance to the AccidentStats class by passing a reference to self
#
# @return [TflApi::Client::AccidentStats] An object to AccidentStats subclass
#
def accident_stats
TflApi::Client::AccidentStats.new(self)
end

# Creates an instance to the AirQuality class by passing a reference to self
#
# @return [TflApi::Client::AirQuality] An object to AirQuality subclass
#
def air_quality
TflApi::Client::AirQuality.new(self)
end

# Creates an instance to the BikePoint class by passing a reference to self
#
# @return [TflApi::Client::BikePoint] An object to BikePoint subclass
Expand Down
2 changes: 1 addition & 1 deletion lib/tfl_api_client/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
#

module TflApi
VERSION = '0.2.1'
VERSION = '0.3.0'
end

0 comments on commit 9d845b7

Please sign in to comment.