Class: Tvdbjson::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/tvdbjson/authentication.rb

Constant Summary collapse

TVDB_API_KEY =
ENV['TVDB_API_KEY']
TVDB_USER_KEY =
ENV['TVDB_USER_KEY']
TVDB_USER_NAME =
ENV['TVDB_USER_NAME']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAuthentication

Returns a new instance of Authentication.



10
11
12
# File 'lib/tvdbjson/authentication.rb', line 10

def initialize()
  new_token
end

Instance Attribute Details

#expiryObject

Returns the value of attribute expiry.



4
5
6
# File 'lib/tvdbjson/authentication.rb', line 4

def expiry
  @expiry
end

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/tvdbjson/authentication.rb', line 4

def token
  @token
end

Instance Method Details

#new_tokenObject



18
19
20
21
# File 'lib/tvdbjson/authentication.rb', line 18

def new_token
  @expiry = Time.now + 86400
  @token = get_token
end

#token_expired?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/tvdbjson/authentication.rb', line 14

def token_expired?
  Time.now >= @expiry
end