Class: JWT::Encode
- Inherits:
-
Object
- Object
- JWT::Encode
- Defined in:
- lib/jwt/encode.rb
Overview
Encoding logic for JWT
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
-
#header_fields ⇒ Object
readonly
Returns the value of attribute header_fields.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(payload, key, algorithm, header_fields) ⇒ Encode
constructor
A new instance of Encode.
Constructor Details
#initialize(payload, key, algorithm, header_fields) ⇒ Encode
Returns a new instance of Encode.
15 16 17 18 19 20 21 |
# File 'lib/jwt/encode.rb', line 15 def initialize(payload, key, algorithm, header_fields) @payload = payload @key = key @algorithm = algorithm @header_fields = header_fields @segments = encode_segments end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
9 10 11 |
# File 'lib/jwt/encode.rb', line 9 def algorithm @algorithm end |
#header_fields ⇒ Object (readonly)
Returns the value of attribute header_fields.
9 10 11 |
# File 'lib/jwt/encode.rb', line 9 def header_fields @header_fields end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/jwt/encode.rb', line 9 def key @key end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
9 10 11 |
# File 'lib/jwt/encode.rb', line 9 def payload @payload end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
9 10 11 |
# File 'lib/jwt/encode.rb', line 9 def segments @segments end |
Class Method Details
.base64url_encode(str) ⇒ Object
11 12 13 |
# File 'lib/jwt/encode.rb', line 11 def self.base64url_encode(str) Base64.encode64(str).tr('+/', '-_').gsub(/[\n=]/, '') end |