module Gigatools

Constants

VERSION

Public Class Methods

find_by_username(username) click to toggle source

This method takes in a username string and returns either a GigatoolsUser object or nil if the user is not found.

# File lib/gigatools.rb, line 11
def self.find_by_username(username)
  uri = URI('http://gigs.gigatools.com/user/'+username+'.json')
  response = Net::HTTP.get_response(uri)

  if response.is_a?(Net::HTTPSuccess)
    json_response = JSON.parse(response.body)

    user_json = json_response[0]["user"]
    events_json = json_response[1]

    return GigatoolsUser.new(user_json, events_json)
  end
end