Class: Nanook

Inherits:
Object
  • Object
show all
Defined in:
lib/nanook.rb,
lib/nanook/key.rb,
lib/nanook/rpc.rb,
lib/nanook/node.rb,
lib/nanook/util.rb,
lib/nanook/block.rb,
lib/nanook/error.rb,
lib/nanook/wallet.rb,
lib/nanook/account.rb,
lib/nanook/version.rb,
lib/nanook/work_peer.rb,
lib/nanook/wallet_account.rb

Overview

Initializing

Connect to the default RPC host at localhost:7076 and with a timeout of 500 seconds:

nanook = Nanook.new

To connect to another host instead:

nanook = Nanook.new("http://ip6-localhost.com:7076")

To give a specific timeout value:

Nanook.new(timeout: 600)
Nanook.new("http://ip6-localhost.com:7076", timeout: 600)

Defined Under Namespace

Classes: Account, Block, Error, Key, Node, Rpc, Util, Wallet, WalletAccount, WorkPeer

Constant Summary collapse

VERSION =
"1.0.2"

Instance Method Summary collapse

Constructor Details

#initialize(uri = Nanook::Rpc::DEFAULT_URI, timeout: Nanook::Rpc::DEFAULT_TIMEOUT) ⇒ Nanook

Arguments

  • uri - RPC host to connect to (default is “localhost:7076”)

  • timeout: - Connection timeout in number of seconds (default is 500)

Examples

Nanook.new # Connect to http://localhost:7076 with 500s timeout

Nanook.new(timeout: 600)
Nanook.new("http://ip6-localhost.com:7076", timeout: 600)


33
34
35
# File 'lib/nanook.rb', line 33

def initialize(uri=Nanook::Rpc::DEFAULT_URI, timeout:Nanook::Rpc::DEFAULT_TIMEOUT)
  @rpc = Nanook::Rpc.new(uri, timeout: timeout)
end

Instance Method Details

#account(account = nil) ⇒ Object

Returns a Nanook::Account instance.

nanook = Nanook.new

 = nanook.
 = nanook.("xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000")


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

def (=nil)
  Nanook::Account.new(@rpc, )
end

#block(block = nil) ⇒ Object



48
49
50
# File 'lib/nanook.rb', line 48

def block(block=nil)
  Nanook::Block.new(@rpc, block)
end

#inspectObject

:nodoc



52
53
54
# File 'lib/nanook.rb', line 52

def inspect # :nodoc
  "#{self.class.name}(rpc: #{@rpc.inspect}, object_id: \"#{"0x00%x" % (object_id << 1)}\")"
end

#key(key = nil) ⇒ Object



56
57
58
# File 'lib/nanook.rb', line 56

def key(key=nil)
  Nanook::Key.new(@rpc, key)
end

#nodeObject



60
61
62
# File 'lib/nanook.rb', line 60

def node
  Nanook::Node.new(@rpc)
end

#wallet(wallet = nil) ⇒ Object



64
65
66
# File 'lib/nanook.rb', line 64

def wallet(wallet=nil)
  Nanook::Wallet.new(@rpc, wallet)
end

#work_peersObject



68
69
70
# File 'lib/nanook.rb', line 68

def work_peers
  Nanook::WorkPeer.new(@rpc)
end