Sha256: 29f71a37ac8a3dfcab99608ec88e0c8929f557665581a80158d65abe72143e17
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
# frozen_string_literal: true require 'weese/bus/stop' require 'weese/bus/route' module Weese # MetroBus related structures. Most important: {MetroBus} module Bus # MetroBus client. Used for accessing MetroBus-related WMATA APIs. class MetroBus include Requests::Requester include Bus::RequiresStop include Bus::RequiresRoute # @return [String] WMATA API key attr_accessor :api_key # # MetroBus client. Used for accessing MetroBus related endpoints # # @param [String] api_key WMATA API key, get one at {http://developer.wmata.com} # def initialize(api_key) @api_key = api_key end # # List of all bus route variants. # {https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6a WMATA Documentation} # # @raise [WeeseError] If request or JSON parse fails # # @return [Hash] JSON Response # def routes fetch( Requests::Request.new( @api_key, Bus::Urls::ROUTES, {} ) ) end # # Nearby bus stops based on latitude, longitude, and radius. # {https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6d WMATA Documentation} # # @param [RadiusAtCoordinates] radius_at_coordinates A radius in meters around a lat/long # # @raise [WeeseError] If request or JSON parse fails # # @return [Hash] JSON Response # def stops(radius_at_coordinates = nil) query = radius_at_coordinates ? radius_at_coordinates.to_h : {} fetch( Requests::Request.new( @api_key, Bus::Urls::STOPS, query ) ) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
weese-1.0.2 | lib/weese/bus/metro_bus.rb |
weese-1.0.1 | lib/weese/bus/metro_bus.rb |
weese-1.0.0 | lib/weese/bus/metro_bus.rb |