Class: Minecraft::JSONAPIv2::Authorization
- Inherits:
-
Object
- Object
- Minecraft::JSONAPIv2::Authorization
- Defined in:
- lib/minecraft_jsonapiv2/authorization.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Authorization
constructor
A new instance of Authorization.
- #key_for(method) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Authorization
Returns a new instance of Authorization.
6 7 8 9 10 11 12 13 14 |
# File 'lib/minecraft_jsonapiv2/authorization.rb', line 6 def initialize(={}) raise "No username given" if [:user].nil? raise "No password given" if [:password].nil? raise "No salt given" if [:salt].nil? @user = [:user] @pass = [:password] @salt = [:salt] @key = nil end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/minecraft_jsonapiv2/authorization.rb', line 4 def key @key end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
4 5 6 |
# File 'lib/minecraft_jsonapiv2/authorization.rb', line 4 def username @username end |
Instance Method Details
#key_for(method) ⇒ Object
16 17 18 |
# File 'lib/minecraft_jsonapiv2/authorization.rb', line 16 def key_for(method) @key = Digest::SHA256.new.update([@user, method, @pass, @salt].join).to_s end |