Class: Yt::Models::Authentication

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Authentication

Returns a new instance of Authentication.



6
7
8
9
10
# File 'lib/yt/models/authentication.rb', line 6

def initialize(data = {})
  @access_token = data['access_token']
  @refresh_token = data['refresh_token']
  @expires_at = expiration_date data.slice('expires_at', 'expires_in')
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



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

def expires_at
  @expires_at
end

#refresh_tokenObject (readonly)

Returns the value of attribute refresh_token.



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

def refresh_token
  @refresh_token
end

Instance Method Details

#expireObject



16
17
18
# File 'lib/yt/models/authentication.rb', line 16

def expire
  @expires_at = 10.years.ago
end

#expired?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/yt/models/authentication.rb', line 12

def expired?
  @expires_at && @expires_at.past?
end