Class: Nanook::PublicKey
- Inherits:
-
Object
- Object
- Nanook::PublicKey
- 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
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
True if keys are equal.
-
#account ⇒ Nanook::Account
Returns the account for a public key.
-
#hash ⇒ Integer
The hash value is used along with #eql? by the Hash class to determine if two objects reference the same hash key.
- #id ⇒ Object
-
#initialize(rpc, key) ⇒ PublicKey
constructor
A new instance of PublicKey.
- #to_s ⇒ String (also: #inspect)
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.
21 22 23 24 |
# File 'lib/nanook/public_key.rb', line 21 def ==(other) other.class == self.class && other.id == id end |
#account ⇒ Nanook::Account
Returns the account for a public key
38 39 40 41 |
# File 'lib/nanook/public_key.rb', line 38 def account account = rpc(:account_get, _access: :account) as_account(account) end |
#hash ⇒ Integer
The hash value is used along with #eql? by the Hash class to determine if two objects reference the same hash key.
31 32 33 |
# File 'lib/nanook/public_key.rb', line 31 def hash id.hash end |
#id ⇒ Object
15 16 17 |
# File 'lib/nanook/public_key.rb', line 15 def id @key end |
#to_s ⇒ String Also known as: inspect
44 45 46 |
# File 'lib/nanook/public_key.rb', line 44 def to_s "#{self.class.name}(id: \"#{short_id}\")" end |