Completed
Push — master ( fde2ba...d387dd )
by Fike
01:07
created

KeyPair.compute_public_key()   A

Complexity

Conditions 3

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 3
1
# frozen_string_literal: true
2
3
# rubocop:disable Style/Documentation
4
5
require_relative 'public_key'
6
require_relative 'private_key'
7
8
module AMA
9
  module Chef
10
    module SSHPrivateKeys
11
      module Model
12
        class KeyPair
13
          attr_accessor :type
14
          attr_accessor :public_key
15
          attr_accessor :private_key
16
          attr_accessor :passphrase
17
          attr_accessor :comment
18
19
          def compute_private_key
20
            klass = ::AMA::Chef::SSHPrivateKeys::Model::PrivateKey
21
            klass.new(private_key, passphrase)
22
          end
23
24
          def compute_public_key
25
            return nil unless public_key && type
26
            klass = ::AMA::Chef::SSHPrivateKeys::Model::PublicKey
27
            klass.new(type, public_key, comment)
28
          end
29
        end
30
      end
31
    end
32
  end
33
end
34