Class: GitcoinBlockchainExplorer::Explorer
- Inherits:
-
Object
- Object
- GitcoinBlockchainExplorer::Explorer
- Defined in:
- lib/gitcoin_blockchain_explorer.rb
Instance Attribute Summary collapse
-
#blockchain_api_base ⇒ Object
Returns the value of attribute blockchain_api_base.
-
#blockr_api_base ⇒ Object
Returns the value of attribute blockr_api_base.
-
#cex_api_base ⇒ Object
Returns the value of attribute cex_api_base.
-
#coinbase_api_base ⇒ Object
Returns the value of attribute coinbase_api_base.
Instance Method Summary collapse
- #address(public_address) ⇒ Object
- #address_transactions(public_address) ⇒ Object
- #block(block_number) ⇒ Object
- #block_transactions(block_number) ⇒ Object
-
#initialize ⇒ Explorer
constructor
A new instance of Explorer.
- #last_block ⇒ Object
- #last_blocks(number_of_blocks = 5) ⇒ Object
- #last_transactions(number_of_transactions = 10) ⇒ Object
- #transaction(transaction_hash) ⇒ Object
Constructor Details
#initialize ⇒ Explorer
Returns a new instance of Explorer.
7 8 9 10 11 12 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 7 def initialize() self.coinbase_api_base = 'https://coinbase.com/api/v1/' self.blockr_api_base = 'http://blockr.io/api/v1/' self.blockchain_api_base = 'http://blockchain.info/' self.cex_api_base = 'https://cex.io/api/' end |
Instance Attribute Details
#blockchain_api_base ⇒ Object
Returns the value of attribute blockchain_api_base.
5 6 7 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 5 def blockchain_api_base @blockchain_api_base end |
#blockr_api_base ⇒ Object
Returns the value of attribute blockr_api_base.
5 6 7 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 5 def blockr_api_base @blockr_api_base end |
#cex_api_base ⇒ Object
Returns the value of attribute cex_api_base.
5 6 7 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 5 def cex_api_base @cex_api_base end |
#coinbase_api_base ⇒ Object
Returns the value of attribute coinbase_api_base.
5 6 7 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 5 def coinbase_api_base @coinbase_api_base end |
Instance Method Details
#address(public_address) ⇒ Object
39 40 41 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 39 def address(public_address) HTTParty.get("#{self.blockr_api_base}address/info/#{public_address}")['data'] end |
#address_transactions(public_address) ⇒ Object
43 44 45 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 43 def address_transactions(public_address) HTTParty.get("#{self.blockr_api_base}address/txs/#{public_address}")['data'] end |
#block(block_number) ⇒ Object
27 28 29 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 27 def block(block_number) HTTParty.get("#{self.blockr_api_base}block/info/#{block_number}")['data'] end |
#block_transactions(block_number) ⇒ Object
31 32 33 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 31 def block_transactions(block_number) HTTParty.get("#{self.blockr_api_base}block/txs/#{block_number}")['data'] end |
#last_block ⇒ Object
14 15 16 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 14 def last_block() HTTParty.get("#{self.blockr_api_base}coin/info")['data'] end |
#last_blocks(number_of_blocks = 5) ⇒ Object
18 19 20 21 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 18 def last_blocks(number_of_blocks = 5) #HTTParty.get("#{Figaro.env.blockr_api_base}block/info/#{last_block_num},#{last_block_num - 1},#{last_block_num - 2},#{last_block_num - 3},#{last_block_num - 4},#{last_block_num - 5}")['data'] HTTParty.get("#{self.blockr_api_base}block/info/#{HTTParty.get("#{self.blockr_api_base}coin/info")['data']['last_block']['nb']}")['data'] end |
#last_transactions(number_of_transactions = 10) ⇒ Object
23 24 25 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 23 def last_transactions(number_of_transactions = 10) HTTParty.get("#{self.blockr_api_base}block/txs/last")['data'] end |
#transaction(transaction_hash) ⇒ Object
35 36 37 |
# File 'lib/gitcoin_blockchain_explorer.rb', line 35 def transaction(transaction_hash) HTTParty.get("#{self.blockr_api_base}tx/info/#{transaction_hash}")['data'] end |