Class: Transistor::Config
- Inherits:
-
Object
- Object
- Transistor::Config
- Defined in:
- lib/transistor.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#id ⇒ Object
Returns the value of attribute id.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#secure ⇒ Object
Returns the value of attribute secure.
Instance Method Summary collapse
- #base_url ⇒ Object
- #credentials ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #protocol ⇒ Object
- #tracking_url(entry_id, format, url) ⇒ Object
- #user_agent ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 |
# File 'lib/transistor.rb', line 12 def initialize @host = 'api.transistor.fm' @secure = true @tracking_url = 'track.transistor.fm/:entry_id.:format/:url' end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/transistor.rb', line 10 def host @host end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/transistor.rb', line 10 def id @id end |
#secret ⇒ Object
Returns the value of attribute secret.
10 11 12 |
# File 'lib/transistor.rb', line 10 def secret @secret end |
#secure ⇒ Object
Returns the value of attribute secure.
10 11 12 |
# File 'lib/transistor.rb', line 10 def secure @secure end |
Instance Method Details
#base_url ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/transistor.rb', line 18 def base_url if self.secure "https://#{self.host}" else "http://#{self.host}" end end |
#credentials ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/transistor.rb', line 26 def credentials { id: self.id, key: self.secret, algorithm: 'sha256' } end |
#protocol ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/transistor.rb', line 38 def protocol if self.secure 'https' else 'http' end end |
#tracking_url(entry_id, format, url) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/transistor.rb', line 46 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 |
#user_agent ⇒ Object
34 35 36 |
# File 'lib/transistor.rb', line 34 def user_agent "Transistor Ruby Client, Version #{Transistor::Version}" end |