Class: Rnp::UserID

Inherits:
Object
  • Object
show all
Defined in:
lib/rnp/userid.rb

Overview

Class that represents a UserID

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr, userid) ⇒ UserID

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of UserID.

Raises:



19
20
21
22
23
# File 'lib/rnp/userid.rb', line 19

def initialize(ptr, userid)
  raise Rnp::Error, 'NULL pointer' if ptr.null?
  @ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy))
  @userid = userid
end

Instance Attribute Details

#ptrObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/rnp/userid.rb', line 16

def ptr
  @ptr
end

Class Method Details

.destroy(ptr) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
# File 'lib/rnp/userid.rb', line 26

def self.destroy(ptr)
  LibRnp.rnp_uid_handle_destroy(ptr)
end

Instance Method Details

#each_signature(&block) ⇒ self, Enumerator

Enumerate each Signature for this key.

Returns:

  • (self, Enumerator)


41
42
43
44
45
# File 'lib/rnp/userid.rb', line 41

def each_signature(&block)
  block or return enum_for(:signature_iterator)
  signature_iterator(&block)
  self
end

#inspectObject



30
31
32
# File 'lib/rnp/userid.rb', line 30

def inspect
  Rnp.inspect_ptr(self)
end

#revoked?Boolean

Check if this key is revoked.

Returns:

  • (Boolean)


57
58
59
60
61
# File 'lib/rnp/userid.rb', line 57

def revoked?
  presult = FFI::MemoryPointer.new(:bool)
  Rnp.call_ffi(:rnp_uid_is_revoked, @ptr, presult)
  presult.read(:bool)
end

#signaturesArray<Signature>

Get a list of all Signatures for this key.

Returns:



50
51
52
# File 'lib/rnp/userid.rb', line 50

def signatures
  each_signature.to_a
end

#to_sObject



34
35
36
# File 'lib/rnp/userid.rb', line 34

def to_s
  @userid
end