Sha256: 5a673c0af18426efdb935b5ace2548fd28092a0e4045ccae9d89e4d56b1225be
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
class Nanook class Account def initialize(account, rpc) @account = account @rpc = rpc end def delegators account_required! rpc(:delegators) end def exists? account_required! response = rpc(:validate_account_number) !response.empty? && response[:valid] == 1 end def history(limit: 1000) account_required! rpc(:account_history, count: limit) end def public_key account_required! rpc(:account_key) end def representative account_required! rpc(:account_representative) end def balance account_required! rpc(:account_balance) end def info account_required! rpc(:account_info) end def ledger(limit: 1) account_required! rpc(:ledger, count: limit) end def pending(limit: 1000) account_required! rpc(:pending, count: limit) end def weight account_required! rpc(:account_weight) end private def rpc(action, params={}) p = @account.nil? ? {} : { account: @account } @rpc.call(action, p.merge(params)) end def account_required! if @account.nil? raise ArgumentError.new("Account must be present") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanook-0.6.3 | lib/nanook/account.rb |
nanook-0.6.0 | lib/nanook/account.rb |