Skip to content

Instantly share code, notes, and snippets.

@nateroling
Created August 6, 2013 03:36
Show Gist options
  • Save nateroling/6161810 to your computer and use it in GitHub Desktop.
Save nateroling/6161810 to your computer and use it in GitHub Desktop.
require 'net/http'
names=%w{ ututtza publicstaticmainvoid netscrape getus }
on_off = {0=>"OFFline", 1=>"ONline"} #hash for when printing out if online
names.each do |name|
uri = URI("http://census.soe.com/xml/get/ps2-beta/character/?name.first_lower=#{name}&c:show=name,online_status%20&c:resolve=online_status") #using planetside 2 API to get character information just need online_status value
status= Net::HTTP.get(uri)
first_junk=status.split #initial split of string to get online or offline
onlinestatus=first_junk.at(9).split('"') #second split which returns 0 when offline and 10 when online in the (1) index of the array
is_online = Integer(onlinestatus[1]) # onlinestatus as an Integer (1 or 0).
puts "#{name} is #{on_off[is_online]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment