Class: Alula::Edgecast

Inherits:
CDN
  • Object
show all
Defined in:
lib/alula/cdns/edgecast.rb

Constant Summary collapse

THRESHOLD =

300kB

300 * 1024

Instance Attribute Summary

Attributes inherited from CDN

#options, #site

Instance Method Summary collapse

Methods inherited from CDN

#cdns, cdns, #initialize, load, register

Constructor Details

This class inherits a constructor from Alula::CDN

Instance Method Details

#url_for(name, opts) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/alula/cdns/edgecast.rb', line 5

def url_for(name, opts)
  file = opts.delete(:file)
  
  hosts = File.size(file) < THRESHOLD ? self.options.small : self.options.large
  
  host = hosts[Digest::MD5.hexdigest(name).to_i(16) % hosts.count]
  File.join(host, name)
end