Class: Mush::Services::Custom

Inherits:
Mush::Service show all
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

#authorize, #get, #post

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

Raises:



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?
  
  options = {}
  path = @service.gsub(/\{\{url\}\}/, url) 
  get(path,options).body.chomp
end