Class: Banano::Protocol

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri: Client::LOCAL_ENDPOINT, timeout: Client::DEFAULT_TIMEOUT) ⇒ Protocol

Returns a new instance of Protocol.



9
10
11
# File 'lib/banano.rb', line 9

def initialize(uri: Client::LOCAL_ENDPOINT, timeout: Client::DEFAULT_TIMEOUT)
  @node = Node.new(uri: uri, timeout: timeout)
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



7
8
9
# File 'lib/banano.rb', line 7

def node
  @node
end

Instance Method Details

#account(address) ⇒ Banano::Account

Returns a new instance of Account.

Example:

 = Banano::Protocol.new.(address: "ban_3e3j...")

Parameters:

  • address (String)

    the id of the account you want to work with

Returns:



20
21
22
# File 'lib/banano.rb', line 20

def (address)
  Banano::Account.new(node: @node, address: address)
end

#block(block) ⇒ Banano::Block

Returns a new instance of Block.

Example:

block = Banano::Protocol.new.block("FBF8B0E...")

Parameters:

  • block (String)

    the id/hash of the block you want to work with

Returns:



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

def block(block)
  Banano::Block.new(node: @node, block: block)
end

#key(key = nil) ⇒ Banano::Key

Returns a new instance of Key.

Example:

key = Banano::Protocol.new.key("3068BB...")

Parameters:

  • key (String) (defaults to: nil)

    a private key

Returns:



42
43
44
# File 'lib/banano.rb', line 42

def key(key = nil)
  Banano::Key.new(node: @node, key: key)
end

#wallet(wallet = nil) ⇒ Banano::Wallet

Returns a new instance of Wallet.

Example:

wallet = Banano::Protocol.new.wallet("000D1BAE...")

Parameters:

  • wallet (String) (defaults to: nil)

    the id of the wallet you want to work with

Returns:



53
54
55
# File 'lib/banano.rb', line 53

def wallet(wallet = nil)
  Banano::Wallet.new(node: @node, wallet: wallet)
end