Class: PkiExpress::DigestAlgorithmAndValue
- Inherits:
-
Object
- Object
- PkiExpress::DigestAlgorithmAndValue
- Defined in:
- lib/pki_express/digest_algorithm_and_value.rb
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Returns the value of attribute algorithm.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #hex_value ⇒ Object
- #hex_value=(value) ⇒ Object
-
#initialize(model) ⇒ DigestAlgorithmAndValue
constructor
A new instance of DigestAlgorithmAndValue.
Constructor Details
#initialize(model) ⇒ DigestAlgorithmAndValue
Returns a new instance of DigestAlgorithmAndValue.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pki_express/digest_algorithm_and_value.rb', line 4 def initialize(model) @algorithm = nil @value = nil unless model.nil? value = model.fetch(:value) algorithm = model.fetch(:algorithm) if value.nil? raise 'The value was not set' end if algorithm.nil? raise 'The algorithm was not set' end @value = Base64.decode64(value).bytes @algorithm = DigestAlgorithm.get_instance_by_api_model(algorithm) end end |
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm.
3 4 5 |
# File 'lib/pki_express/digest_algorithm_and_value.rb', line 3 def algorithm @algorithm end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/pki_express/digest_algorithm_and_value.rb', line 3 def value @value end |
Instance Method Details
#hex_value ⇒ Object
23 24 25 |
# File 'lib/pki_express/digest_algorithm_and_value.rb', line 23 def hex_value @value.map { |b| b.to_s(16).rjust(2,'0') }.join.upcase end |
#hex_value=(value) ⇒ Object
27 28 29 |
# File 'lib/pki_express/digest_algorithm_and_value.rb', line 27 def hex_value=(value) @value = [value].pack('H*').unpack('C*') end |