Class: Altcha::Challenge

Inherits:
Object
  • Object
show all
Defined in:
lib/altcha.rb

Overview

Class representing a challenge with its attributes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm:, challenge:, maxnumber: nil, salt:, signature:) ⇒ Challenge

Returns a new instance of Challenge.



43
44
45
46
47
48
49
# File 'lib/altcha.rb', line 43

def initialize(algorithm:, challenge:, maxnumber: nil, salt:, signature:)
  @algorithm = algorithm
  @challenge = challenge
  @maxnumber = maxnumber
  @salt = salt
  @signature = signature
end

Instance Attribute Details

#algorithmObject

Returns the value of attribute algorithm.



41
42
43
# File 'lib/altcha.rb', line 41

def algorithm
  @algorithm
end

#challengeObject

Returns the value of attribute challenge.



41
42
43
# File 'lib/altcha.rb', line 41

def challenge
  @challenge
end

#maxnumberObject

Returns the value of attribute maxnumber.



41
42
43
# File 'lib/altcha.rb', line 41

def maxnumber
  @maxnumber
end

#saltObject

Returns the value of attribute salt.



41
42
43
# File 'lib/altcha.rb', line 41

def salt
  @salt
end

#signatureObject

Returns the value of attribute signature.



41
42
43
# File 'lib/altcha.rb', line 41

def signature
  @signature
end

Instance Method Details

#to_json(options = {}) ⇒ String

Converts the Challenge object to a JSON string.

Parameters:

  • options (Hash) (defaults to: {})

    options to customize JSON encoding.

Returns:

  • (String)

    JSON representation of the Challenge object.



54
55
56
57
58
59
60
61
62
# File 'lib/altcha.rb', line 54

def to_json(options = {})
  {
    algorithm: @algorithm,
    challenge: @challenge,
    maxnumber: @maxnumber,
    salt: @salt,
    signature: @signature
  }.to_json(options)
end