Class: Stream::APIURLGenerator
- Inherits:
-
URLGenerator
- Object
- URLGenerator
- Stream::APIURLGenerator
- Defined in:
- lib/stream/url.rb
Instance Attribute Summary
Attributes inherited from URLGenerator
Instance Method Summary collapse
-
#initialize(options) ⇒ APIURLGenerator
constructor
A new instance of APIURLGenerator.
Constructor Details
#initialize(options) ⇒ APIURLGenerator
Returns a new instance of APIURLGenerator.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stream/url.rb', line 9 def initialize() @options = location = make_location([:location]) location ||= "api" api_version = [:api_version] ? [: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 = [: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 |