Sha256: d05c77f4f4998757342e674d598b9cb94fd0214cac6b7e4a3a202ee44b555856
Contents?: true
Size: 907 Bytes
Versions: 2
Compression:
Stored size: 907 Bytes
Contents
# frozen_string_literal: true require 'coinmarketcap_free/helper' module CoinmarketcapFree class BASE protected # @param [URI] url # @return [String] def request_to_read_data(url) response = Net::HTTP.get_response(url, Hash('Accept': '*/*')) raise HTTPBadResponse if response.code.match? /[45][0-9]{2}/ response.read_body end # @return [String] def generate_uri_for_data raise NotImplementedError end public attr_reader :get_data # @return [false, true] true data update is good If false is bad request, wrong parameter values, or the API has been updated def update begin url = generate_uri_for_data data = request_to_read_data(url) rescue @get_data = nil false else @get_data = data true end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
coinmarketcap_free-0.1.4 | lib/coinmarketcap_free/base.rb |
coinmarketcap_free-0.1.3 | lib/coinmarketcap_free/base.rb |