Class: Protocol::HTTP::Header::Authorization
- Inherits:
-
Object
- Object
- Protocol::HTTP::Header::Authorization
- Defined in:
- lib/protocol/http/header/authorization.rb
Overview
Used for basic authorization.
Constant Summary collapse
- KEY =
"Authorization"
Instance Method Summary collapse
- #encoded ⇒ Object
-
#initialize(username, password) ⇒ Authorization
constructor
A new instance of Authorization.
- #to_ary ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(username, password) ⇒ Authorization
Returns a new instance of Authorization.
33 34 35 36 |
# File 'lib/protocol/http/header/authorization.rb', line 33 def initialize(username, password) @username = username @password = password end |
Instance Method Details
#encoded ⇒ Object
42 43 44 |
# File 'lib/protocol/http/header/authorization.rb', line 42 def encoded "#{@username}:#{@password}" end |
#to_ary ⇒ Object
38 39 40 |
# File 'lib/protocol/http/header/authorization.rb', line 38 def to_ary return KEY, self.to_str end |
#to_str ⇒ Object
46 47 48 |
# File 'lib/protocol/http/header/authorization.rb', line 46 def to_str 'Basic %s' % Base64.strict_encode64(self.encoded) end |