Skip to content

Instantly share code, notes, and snippets.

@JamesHarrison
Created May 30, 2009 19:42
Show Gist options
  • Save JamesHarrison/120612 to your computer and use it in GitHub Desktop.
Save JamesHarrison/120612 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'reve'
path = "assets.msh"
file = File.open(path,'a+')
cid = 123098319308
uid = 20391123123
key = "YOURKEY"
api = Reve::API.new(uid,key)
assets = api.personal_assets_list(:characterid=>cid)
Marshal.dump(assets,file)
file.close
require 'rubygems'
require 'reve'
require 'open-uri'
require 'hpricot'
require 'progressbar'
require 'mysql'
path = "assets.msh"
file = File.open(path,'a+')
cid = 123098319308
uid = 20391123123
key = "YOURKEY"
api = Reve::API.new(uid,key)
assets = Marshal.load(file)
asset_count = 0
assets.each do |container|
asset_count = asset_count + container.assets.length
end
p = ProgressBar.new("Valuating",asset_count)
file.close
def get_price(type_id)
ecxml = "http://api.eve-central.com/api/marketstat?typeid=#{type_id}&regionlimit=10000002"
x = Hpricot::XML(open(ecxml))
return (x/"evec_api/marketstat/type/buy/avg").innerHTML.to_f
end
assetlist = ""
total = 0.0
assets.each do |container|
container.assets.each do |asset|
p.inc
price = get_price(asset.type_id)
assetlist = assetlist + "Item ID #{asset.item_id} is Type ID #{asset.type_id} with value #{price} and quantity #{asset.quantity}, total value #{price*asset.quantity.to_f}\r\n"
total = total + (price*asset.quantity.to_f)
end
end
File.open("valuator.txt","a+") do |f|
f << "Total value of assets: #{total}"
f << assetlist
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment