Class: Mush::Services::Custom
- Inherits:
-
Mush::Service
- Object
- Mush::Service
- Mush::Services::Custom
- Defined in:
- lib/mush/services/custom.rb
Overview
General class to accept a custom shortener e.g. short.en?url={url}&api_key=982AAJHKDLFDF
Instance Method Summary collapse
Methods inherited from Mush::Service
Instance Method Details
#set_service(service_url) ⇒ Object
9 10 11 |
# File 'lib/mush/services/custom.rb', line 9 def set_service(service_url) @service = service_url end |
#shorten(url) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/mush/services/custom.rb', line 13 def shorten(url) raise InvalidURI.new("Please provide a valid URI") if url.empty? = {} path = @service.gsub(/\{\{url\}\}/, url) get(path,).body.chomp end |