Class: VoiceBase::Client::Token
- Inherits:
-
Object
- Object
- VoiceBase::Client::Token
- Defined in:
- lib/voicebase/client/token.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(token, timeout = Float::INFINITY) ⇒ Token
constructor
A new instance of Token.
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_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/voicebase/client/token.rb', line 3 def created_at @created_at end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/voicebase/client/token.rb', line 3 def timeout @timeout end |
#token ⇒ Object
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
12 13 14 |
# File 'lib/voicebase/client/token.rb', line 12 def expired? Time.now > created_at + (timeout / 1000.to_f) end |