Class: Shawty

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

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Shawty

@server: myserver.com



4
5
6
7
# File 'lib/shawty_client.rb', line 4

def initialize(server)
  require 'net/http'
  @server = URI.parse server
end

Instance Method Details

#expand(url) ⇒ Object



15
16
17
18
19
20
# File 'lib/shawty_client.rb', line 15

def expand url
  path = URI.parse(url).path
  start do |http|
    http.get(path)['Location']
  end
end

#shrink(url) ⇒ Object



9
10
11
12
13
# File 'lib/shawty_client.rb', line 9

def shrink url
  start do |http|
    http.post("/#{url}", '').read_body
  end
end