Class: VoiceBase::Client::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/voicebase/client/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, timeout = Float::INFINITY) ⇒ Token

Returns a new instance of Token.



5
6
7
8
9
10
# File 'lib/voicebase/client/token.rb', line 5

def initialize(token, timeout = Float::INFINITY)
  raise VoiceBase::AuthenticationError, "Authentication token cannot be empty" unless token
  @token      = token
  @created_at = Time.now
  @timeout    = timeout
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/voicebase/client/token.rb', line 3

def created_at
  @created_at
end

#timeoutObject

Returns the value of attribute timeout.



3
4
5
# File 'lib/voicebase/client/token.rb', line 3

def timeout
  @timeout
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/voicebase/client/token.rb', line 3

def token
  @token
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/voicebase/client/token.rb', line 12

def expired?
  Time.now > created_at + (timeout / 1000.to_f)
end