class Blockchain::StatisticsExplorer

Attributes

client[R]

Public Class Methods

new(base_url = nil, api_code = nil) click to toggle source
# File lib/blockchain/statistics.rb, line 10
def initialize(base_url = nil, api_code = nil)
    @client = Client.new(base_url, api_code)
end

Public Instance Methods

get_chart(chart_type, timespan = nil, rolling_average = nil) click to toggle source
# File lib/blockchain/statistics.rb, line 26
def get_chart(chart_type, timespan = nil, rolling_average = nil)
    params = { 'format' => 'json' }
    if !timespan.nil? then params['timespan'] = timespan end
    if !rolling_average.nil? then params['rollingAverage'] = rolling_average end
    resource = 'charts/' + chart_type
    response = @client.call_api(resource, method: 'get', data: params)
    return ChartResponse.new(JSON.parse(response))
end
get_pools(timespan = 4) click to toggle source
# File lib/blockchain/statistics.rb, line 35
def get_pools(timespan = 4)
    if timespan < 1 || timespan > 10
        raise ArgumentError, 'timespan must be between 1 and 10'
    end
    params = { 'format' => 'json', 'timespan' => timespan.to_s + 'days' }
    resource = 'pools'
    response = @client.call_api(resource, method: 'get', data: params)
    return JSON.parse(response)
end
get_statistics() click to toggle source
# File lib/blockchain/statistics.rb, line 19
def get_statistics()
    params = { 'format' => 'json' }
    resource = 'stats'
    response = @client.call_api(resource, method: 'get', data: params)
    return StatisticsResponse.new(JSON.parse(response))
end
proxy(method_name, *args) click to toggle source
# File lib/blockchain/statistics.rb, line 14
def proxy(method_name, *args)
    warn "[DEPRECATED] avoid use of static methods, use an instance of StatisticsExplorer class instead."
    send(method_name, *args)
end