class Ryp::Client
Attributes
client[R]
network[R]
Public Class Methods
new(network)
click to toggle source
ETH: www.blockcypher.com/dev/ethereum/ BTC: www.blockcypher.com/dev/bitcoin/
# File lib/ryp/client.rb, line 8 def initialize(network) @network = network.to_s.downcase.to_sym raise ArgumentError, 'Unknown Network' if network.nil? || network == :unknown @client = send("#{network}_data_source") end
Public Instance Methods
address(arg)
click to toggle source
# File lib/ryp/client.rb, line 20 def address(arg) data_class('Address').new.tap do |address| address.parse! client.address(arg) end end
data_class(content_type)
click to toggle source
`content_type` accepts Address and Transaction
# File lib/ryp/client.rb, line 27 def data_class(content_type) network_name = Ryp.ticker_to_name(network) Ryp.const_get("#{network_name}#{content_type}") end
transaction(arg)
click to toggle source
# File lib/ryp/client.rb, line 14 def transaction(arg) data_class('Transaction').new.tap do |transaction| transaction.parse! client.transaction(arg) end end
Private Instance Methods
btc_data_source()
click to toggle source
# File lib/ryp/client.rb, line 38 def btc_data_source @btc_client ||= Ryp::DataSource::BlockCypher.new(:btc) end
eth_data_source()
click to toggle source
# File lib/ryp/client.rb, line 34 def eth_data_source @eth_client ||= Ryp::DataSource::BlockCypher.new(:eth) end