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