Class: Cudan::Util

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

Class Method Summary collapse

Class Method Details

.parse_url(url) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/cudan/base_cudan.rb', line 61

def self::parse_url url
    hostpath = url.slice(url.index('://')+3, url.size)
    if pathstart = hostpath.index('/')
        host = hostpath.slice(0, pathstart)
        path = hostpath.slice(pathstart, hostpath.size)
    else
        host = hostpath
        path = '/'
    end
    if portstart = host.index(':')
        host, port = host.split(':')
        port = port.to_i
    else
        port = 80
    end
    [host, port, path]
end