class Stream::APIURLGenerator
Public Class Methods
new(options)
click to toggle source
Calls superclass method
# File lib/stream/url.rb, line 9 def initialize(options) super() @options = options location = make_location(options[:location]) location ||= 'api' api_version = options[:api_version] || 'v1.0' if ENV['STREAM_URL'] uri = URI.parse(ENV['STREAM_URL']) scheme = uri.scheme host = uri.host port = uri.port else scheme = 'https' host = options[:api_hostname] port = 443 end unless ENV['STREAM_URL'] =~ /localhost/ host_parts = host.split('.') host = host_parts.slice(1..-1).join('.') if host_parts.length == 3 host = "#{location}.#{host}" if location end @base_path = "/api/#{api_version}" @url = "#{scheme}://#{host}:#{port}#{@base_path}" end
Private Instance Methods
make_location(loc)
click to toggle source
# File lib/stream/url.rb, line 36 def make_location(loc) case loc when 'us-east' 'us-east-api' when 'eu-west' 'eu-west-api' when 'singapore' 'singapore-api' else loc end end