Class: Token

Inherits:
Object
  • Object
show all
Defined in:
lib/track-r/token.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Token

Returns a new instance of Token.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/track-r/token.rb', line 2

def initialize(options = {})
  @token = case
           when options.include?(:token)
             options[:token]
           when options.include?(:username) &&
             options.include?(:password)
             # If a token is not provided, it can be generated by passing a
             # hash with :user and :password keys
             get_token(options[:username],
                       options[:password]
                      )
           else
             raise ArgumentError, "Invalid argument, expecting either <:token> or <:username> and <:password>"
           end
end

Instance Method Details

#to_sObject



18
19
20
# File 'lib/track-r/token.rb', line 18

def to_s
  @token
end