class Webhoseio

Public Class Methods

new(token) click to toggle source
# File webhoseio.rb, line 5
def initialize(token)
  @next = ''
  @token = token
end

Public Instance Methods

get_next() click to toggle source
# File webhoseio.rb, line 17
def get_next
  response = Net::HTTP.get_response(@next)

  unless response.kind_of? Net::HTTPSuccess
    raise 'Server replied with status code ' + response.code
  end

  json = JSON.parse(response.body)
  @next = URI::parse('https://webhose.io' + json['next'])
  json
end
query(end_point_str, param_dict = {}) click to toggle source
# File webhoseio.rb, line 10
def query(end_point_str, param_dict = {})
  param_dict[:token] ||= @token
  param_dict[:format] ||= 'json'
  @next = URI::parse('https://webhose.io/' + end_point_str + '?' + URI.encode_www_form(param_dict))
  get_next
end