Class: RubyGPG2::StatusLines::KeyCreated

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_gpg2/status_lines/key_created.rb

Constant Summary collapse

KEY_TYPES =
{
    'B' => :primary_and_subkey,
    'P' => :primary,
    'S' => :subkey
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ KeyCreated

Returns a new instance of KeyCreated.



25
26
27
28
29
30
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 25

def initialize(opts)
  @raw = opts[:raw]
  @key_type = opts[:key_type]
  @key_fingerprint = opts[:key_fingerprint]
  @handle = opts[:handle]
end

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



19
20
21
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 19

def handle
  @handle
end

#key_fingerprintObject (readonly)

Returns the value of attribute key_fingerprint.



19
20
21
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 19

def key_fingerprint
  @key_fingerprint
end

#key_typeObject (readonly)

Returns the value of attribute key_type.



19
20
21
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 19

def key_type
  @key_type
end

#rawObject (readonly)

Returns the value of attribute raw.



19
20
21
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 19

def raw
  @raw
end

Class Method Details

.parse(line) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 10

def self.parse(line)
  match = line.match(/^\[GNUPG:\] KEY_CREATED (.) (.*?)(?: (.*))?$/)
  new(
      raw: line,
      key_type: KEY_TYPES[match[1]],
      key_fingerprint: match[2],
      handle: match[3])
end

Instance Method Details

#==(other) ⇒ Object



36
37
38
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 36

def ==(other)
  other.class == self.class && other.state == state
end

#typeObject



32
33
34
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 32

def type
  :key_created
end