Class: Nanook::PublicKey

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/nanook/public_key.rb

Overview

The Nanook::PublicKey class lets you manage your node's keys.

Constant Summary

Constants included from Util

Util::STEP

Instance Method Summary collapse

Constructor Details

#initialize(rpc, key) ⇒ PublicKey

Returns a new instance of PublicKey.



10
11
12
13
# File 'lib/nanook/public_key.rb', line 10

def initialize(rpc, key)
  @rpc = rpc
  @key = key.to_s
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Returns true if keys are equal.

Parameters:

Returns:

  • (Boolean)

    true if keys are equal



21
22
23
24
# File 'lib/nanook/public_key.rb', line 21

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

#accountNanook::Account

Returns the account for a public key

Returns:



38
39
40
41
# File 'lib/nanook/public_key.rb', line 38

def 
   = rpc(:account_get, _access: :account)
  ()
end

#hashInteger

The hash value is used along with #eql? by the Hash class to determine if two objects reference the same hash key.

Returns:

  • (Integer)


31
32
33
# File 'lib/nanook/public_key.rb', line 31

def hash
  id.hash
end

#idObject



15
16
17
# File 'lib/nanook/public_key.rb', line 15

def id
  @key
end

#to_sString Also known as: inspect

Returns:

  • (String)


44
45
46
# File 'lib/nanook/public_key.rb', line 44

def to_s
  "#{self.class.name}(id: \"#{short_id}\")"
end