Class: Altcha::Payload
- Inherits:
-
Object
- Object
- Altcha::Payload
- Defined in:
- lib/altcha.rb
Overview
Class representing the payload of a challenge.
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Returns the value of attribute algorithm.
-
#challenge ⇒ Object
Returns the value of attribute challenge.
-
#number ⇒ Object
Returns the value of attribute number.
-
#salt ⇒ Object
Returns the value of attribute salt.
-
#signature ⇒ Object
Returns the value of attribute signature.
Class Method Summary collapse
-
.from_json(string) ⇒ Payload
Creates a Payload object from a JSON string.
Instance Method Summary collapse
-
#initialize(algorithm:, challenge:, number:, salt:, signature:) ⇒ Payload
constructor
A new instance of Payload.
-
#to_json(options = {}) ⇒ String
Converts the Payload object to a JSON string.
Constructor Details
#initialize(algorithm:, challenge:, number:, salt:, signature:) ⇒ Payload
Returns a new instance of Payload.
69 70 71 72 73 74 75 |
# File 'lib/altcha.rb', line 69 def initialize(algorithm:, challenge:, number:, salt:, signature:) @algorithm = algorithm @challenge = challenge @number = number @salt = salt @signature = signature end |
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm.
67 68 69 |
# File 'lib/altcha.rb', line 67 def algorithm @algorithm end |
#challenge ⇒ Object
Returns the value of attribute challenge.
67 68 69 |
# File 'lib/altcha.rb', line 67 def challenge @challenge end |
#number ⇒ Object
Returns the value of attribute number.
67 68 69 |
# File 'lib/altcha.rb', line 67 def number @number end |
#salt ⇒ Object
Returns the value of attribute salt.
67 68 69 |
# File 'lib/altcha.rb', line 67 def salt @salt end |
#signature ⇒ Object
Returns the value of attribute signature.
67 68 69 |
# File 'lib/altcha.rb', line 67 def signature @signature end |
Class Method Details
.from_json(string) ⇒ Payload
Creates a Payload object from a JSON string.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/altcha.rb', line 93 def self.from_json(string) data = JSON.parse(string) new( algorithm: data['algorithm'], challenge: data['challenge'], number: data['number'], salt: data['salt'], signature: data['signature'] ) end |
Instance Method Details
#to_json(options = {}) ⇒ String
Converts the Payload object to a JSON string.
80 81 82 83 84 85 86 87 88 |
# File 'lib/altcha.rb', line 80 def to_json( = {}) { algorithm: @algorithm, challenge: @challenge, number: @number, salt: @salt, signature: @signature }.to_json() end |