Class: Lisk::Delegate
- Inherits:
-
Object
- Object
- Lisk::Delegate
- Defined in:
- lib/lisk/delegate.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#api ⇒ Object
Returns the value of attribute api.
-
#delegate_name ⇒ Object
Returns the value of attribute delegate_name.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
-
#registered ⇒ Object
Returns the value of attribute registered.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#secret_secondary ⇒ Object
Returns the value of attribute secret_secondary.
Instance Method Summary collapse
-
#initialize(api, delegate_name) ⇒ Delegate
constructor
A new instance of Delegate.
- #is_registered? ⇒ Boolean
- #register ⇒ Object
- #set_secrets(secret, second_secret = nil) ⇒ Object
Constructor Details
#initialize(api, delegate_name) ⇒ Delegate
Returns a new instance of Delegate.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lisk/delegate.rb', line 13 def initialize api, delegate_name @api = api @delegate_name = delegate_name delegate = @api.delegates_get_by_name delegate_name if delegate.nil? @registered = false else @registered = true @address = delegate["address"] @public_key = delegate["publicKey"] end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
7 8 9 |
# File 'lib/lisk/delegate.rb', line 7 def address @address end |
#api ⇒ Object
Returns the value of attribute api.
5 6 7 |
# File 'lib/lisk/delegate.rb', line 5 def api @api end |
#delegate_name ⇒ Object
Returns the value of attribute delegate_name.
6 7 8 |
# File 'lib/lisk/delegate.rb', line 6 def delegate_name @delegate_name end |
#public_key ⇒ Object
Returns the value of attribute public_key.
8 9 10 |
# File 'lib/lisk/delegate.rb', line 8 def public_key @public_key end |
#registered ⇒ Object
Returns the value of attribute registered.
11 12 13 |
# File 'lib/lisk/delegate.rb', line 11 def registered @registered end |
#secret ⇒ Object
Returns the value of attribute secret.
9 10 11 |
# File 'lib/lisk/delegate.rb', line 9 def secret @secret end |
#secret_secondary ⇒ Object
Returns the value of attribute secret_secondary.
10 11 12 |
# File 'lib/lisk/delegate.rb', line 10 def secret_secondary @secret_secondary end |
Instance Method Details
#is_registered? ⇒ Boolean
26 27 28 |
# File 'lib/lisk/delegate.rb', line 26 def is_registered? return registered end |
#register ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lisk/delegate.rb', line 35 def register if not self.is_registered? delegate = {} delegate[:username] = @delegate_name if not @secret_secondary.nil? delegate[:secondSecret] = @secret_secondary end if not @secret.nil? delegate[:secret] = @secret registration = api.delegates_put delegate return registration else return false end else return false end end |
#set_secrets(secret, second_secret = nil) ⇒ Object
30 31 32 33 |
# File 'lib/lisk/delegate.rb', line 30 def set_secrets secret, second_secret = nil @secret = secret @secret_secondary = second_secret end |