Class: TflApi::Client::BikePoint

Inherits:
Object
  • Object
show all
Defined in:
lib/tfl_api_client/bike_point.rb

Overview

This class communicates with the TFL “/BikePoint” API to obtain details about bike points locations based upon their IDs or by their latitude and longitude values.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ BikePoint

Initialize the BikePoint object and store the reference to Client object

Parameters:

  • client (Client)

    the client object



40
41
42
# File 'lib/tfl_api_client/bike_point.rb', line 40

def initialize(client)
  @client = client
end

Instance Method Details

#location(id) ⇒ hash

Returns the all details known by the TFL service for the given BikePoint id.

Parameters:

  • id (String)

    the TFL BikePoint id

Returns:

  • (hash)

    A hash containing the details of the given BikePoint



59
60
61
# File 'lib/tfl_api_client/bike_point.rb', line 59

def location(id)
  @client.get("/BikePoint/#{id}")
end

#locationsArray

Returns all BikePoint locations known by the TFL service

Returns:

  • (Array)

    An array of hashes containing all BikePoints and their details



48
49
50
# File 'lib/tfl_api_client/bike_point.rb', line 48

def locations
  @client.get('/BikePoint')
end

#locations_within_bounding_box(sw_latitude, sw_longitude, ne_latitude, ne_longitude) ⇒ Array

Returns all BikePoint locations known by the TFL service within a the given box based upon it’s defined corner locations.

Parameters:

  • sw_latitude (String)

    the south-west latitude positional value of the bounding box

  • sw_longitude (String)

    the south-west longitude positional value of the bounding box

  • ne_latitude (String)

    the north-east latitude positional value of the bounding box

  • ne_longitude (String)

    the north-east longitude positional value of the bounding box

Returns:

  • (Array)

    An array of hashes containing all BikePoints and their details



87
88
89
90
# File 'lib/tfl_api_client/bike_point.rb', line 87

def locations_within_bounding_box(sw_latitude, sw_longitude, ne_latitude, ne_longitude)
  uri_params = { swLat: sw_latitude, swLon: sw_longitude, neLat: ne_latitude, neLon: ne_longitude }
  @client.get('/BikePoint', uri_params)
end

#locations_within_locus(latitude, longitude, radius) ⇒ Array

Returns all BikePoint locations known by the TFL service within a particular position or place (a locus).

Parameters:

  • latitude (String)

    the latitude value

  • longitude (String)

    the longitude value

  • radius (String)

    the radius of the area to cover

Returns:

  • (Array)

    An array of hashes containing all BikePoints and their details



72
73
74
75
# File 'lib/tfl_api_client/bike_point.rb', line 72

def locations_within_locus(latitude, longitude, radius)
  uri_params = { lat: latitude, lon: longitude, radius: radius }
  @client.get('/BikePoint', uri_params)
end

#search(query) ⇒ Array

Returns all BikePoint locations known by the TFL service within based upon the given search query.

Parameters:

  • query (String)

    the query term to search for

Returns:

  • (Array)

    An array of hashes containing all BikePoints and their details



99
100
101
# File 'lib/tfl_api_client/bike_point.rb', line 99

def search(query)
  @client.get('/BikePoint/Search', { query: query })
end