Class: Sha256Seal::Builder
- Inherits:
-
Object
- Object
- Sha256Seal::Builder
- Defined in:
- lib/sha256_seal.rb
Overview
Main class for the Sha256Seal library.
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value, secret, field) ⇒ Builder
constructor
A new instance of Builder.
- #signed_value ⇒ Object
- #signed_value? ⇒ Boolean
Constructor Details
#initialize(value, secret, field) ⇒ Builder
Returns a new instance of Builder.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sha256_seal.rb', line 11 def initialize(value, secret, field) @value = value.to_s @secret = secret.to_s @field = field.to_s i = @value.scan(@field).length return if i.equal?(1) raise ::ArgumentError, "#{i} #{@field.inspect} occurrences instead of 1." end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
9 10 11 |
# File 'lib/sha256_seal.rb', line 9 def field @field end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
9 10 11 |
# File 'lib/sha256_seal.rb', line 9 def secret @secret end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/sha256_seal.rb', line 9 def value @value end |
Instance Method Details
#signed_value ⇒ Object
23 24 25 |
# File 'lib/sha256_seal.rb', line 23 def signed_value value.gsub(field, signature) end |
#signed_value? ⇒ Boolean
27 28 29 |
# File 'lib/sha256_seal.rb', line 27 def signed_value? signature.eql?(field) end |