Method: EVURI#localname

Defined in:
lib/rwd/net.rb

#localnameObject



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/rwd/net.rb', line 202

def localname
  protocol  = @protocol
  userpass  = @userpass
  host  = @host
  port  = @port
  path  = @path
  vars  = varstring
  anchor  = @anchor

  protocol  = nil  if @protocol.empty?
  userpass  = nil  if @userpass.empty?
  host  = nil  if @host.empty?
  port  = nil  if @port.zero?
  path  = nil  if @path.empty?
  vars  = nil  if @vars.empty?
  anchor  = nil  if @anchor.empty?

  path  = "#{path}." if path =~ /[\/\\]$/

  f = MD5.new(protocol.to_s + userpass.to_s + host.to_s + port.to_s + File.dirname(path.to_s) + vars.to_s).to_s
  e = File.basename(path.to_s).gsub(/[^\w\.\-]/, "_").gsub(/_+/, "_")
  res = f + "." + e
  res.gsub!(/[^\w]+$/, "")

  return res
end