lib/transistor.rb in transistor-client-0.0.1 vs lib/transistor.rb in transistor-client-0.0.2
- old
+ new
@@ -10,10 +10,11 @@
attr_accessor :id, :secret, :host, :secure
def initialize
@host = 'api.transistor.fm'
@secure = true
+ @tracking_url = 'track.transistor.fm/:entry_id.:format/:url'
end
def base_url
if self.secure
"https://#{self.host}"
@@ -30,9 +31,25 @@
}
end
def user_agent
"Transistor Ruby Client, Version #{Transistor::Version}"
+ end
+
+ def protocol
+ if self.secure
+ 'https'
+ else
+ 'http'
+ end
+ end
+
+ def tracking_url(entry_id, format, url)
+ full_url = @tracking_url
+ .gsub(':entry_id', entry_id.to_s)
+ .gsub(':format', format.to_s)
+ .gsub(':url', url)
+ [self.protocol, '://', full_url].join()
end
end
def self.setup
self.config ||= Config.new
\ No newline at end of file