module Trackerific::Services
Public Class Methods
[](name)
click to toggle source
Finds a service by the given name @param [Symbol] name The name of the service @return A descendant of Trackerific::Services::Base
or nil for no match @api public
# File lib/trackerific/services.rb, line 10 def [](name) @services[name] end
[]=(name, _class)
click to toggle source
Registers a service by the given name and class @param [Symbol] name The name of the service @param [Trackerific::Services::Base] _class The base class to register @api public
# File lib/trackerific/services.rb, line 18 def []=(name, _class) unless _class.superclass == Trackerific::Services::Base raise ArgumentError, "Expected a Trackerific::Services::Base, got #{_class.inspect}", caller end @services[name] = _class end
find_by_package_id(id)
click to toggle source
Finds the tracking service(s) that are capable of tracking the given package ID @param [String] id The package identifier @return [Array, Trackerific::Services::Base] The services that are capable of tracking the given ID. @example Find out which service providers can track a FedEx
ID
Trackerific::Services.find_by_package_id "183689015000001"
@api public
# File lib/trackerific/services.rb, line 36 def find_by_package_id(id) @services.map {|n,s| s if s.can_track?(id) }.compact end