Ruby

You are here:
< Back

Ruby Installation

Ruby can be downloaded here.

For further informations on how to install Ruby on your operating system :

Windows : RubyInstaller

Unix & Linux: rbenv and rvm

Installation

Add this line to your application’s Gemfile and then execute bundle

gem 'qredit-client'

Or install it from the command line

$ gem install qredit-client

Usage

Basic

require 'qredit/client'

// V2
connection = Qredit::Client::Connection.new(host: 'http://my.qredit.node:port/api/', version: 2)
... 

Connections

require 'qredit/client'

manager = Qredit::Client::ConnectionManager.new()

manager.connect(Qredit::Client::Connection.new({
  host: "http://my.qredit.node:port/api/",
  version: 2
}), 'main')

manager.connect(Qredit::Client::Connection.new({
  host: "http://my.qredit.node:port/api/",
  version: 2
}), 'backup')

begin
  response = manager.connection('main').accounts.balance('DQ7VAW7u171hwDW75R1BqfHbA9yiKRCBSh').body
rescue Exception => e
  response = manager.connection('backup').accounts.balance('DQ7VAW7u171hwDW75R1BqfHbA9yiKRCBSh').body
end

if response["success"]
  puts response["balance"]
else
  puts 'Both the main and backup node did not respond.'
end

Blocks V2

// ...
response = connection.blocks.all().body

puts response

... > {"meta"=>{"count"=>100,
... > ...
... > }}

Delegates V2

// ...
response = connection.delegates.all().body

puts response

... > {"meta"=>{"count"=>100,
... > ...
... > }}

Node – V2

// ...
response = connection.node.status().body

puts response

... > {"data"=>{
... > ...
... > }}

Peers – V2

// ...
response = connection.peers.all().body

puts response

... > {"meta"=>{"count"=>
... > ...
... > }}

Transactions – V2

// ...
response = connection.transactions.all().body

puts response

... > {"meta"=>{"count"=>100,
... > ...
... > }}

Votes – V2

// ...
response = connection.votes.all().body

puts response

... > {"meta"=>{"count"=>100,
... > ...
... > }}

Wallets – V2

// ...
response = connection.wallets.all().body

puts response

... > {"meta"=>{"count"=>100,
... > ...
... > }}
Last Updated On January 15, 2019