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
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ KeyCreated

Returns a new instance of KeyCreated.



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

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.



22
23
24
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 22

def handle
  @handle
end

#key_fingerprintObject (readonly)

Returns the value of attribute key_fingerprint.



22
23
24
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 22

def key_fingerprint
  @key_fingerprint
end

#key_typeObject (readonly)

Returns the value of attribute key_type.



22
23
24
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 22

def key_type
  @key_type
end

#rawObject (readonly)

Returns the value of attribute raw.



22
23
24
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 22

def raw
  @raw
end

Class Method Details

.parse(line) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 12

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



40
41
42
# File 'lib/ruby_gpg2/status_lines/key_created.rb', line 40

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

#typeObject



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

def type
  :key_created
end