Class: Shawty
- Inherits:
-
Object
- Object
- Shawty
- Defined in:
- lib/shawty-client.rb
Instance Method Summary collapse
- #expand(url) ⇒ Object
-
#initialize(server) ⇒ Shawty
constructor
@server: myserver.com.
- #shrink(url) ⇒ Object
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 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 |