diablo3-simple 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/D3/hero.rb +31 -0
- data/lib/diablo3-simple.rb +27 -0
- metadata +47 -0
data/lib/D3/hero.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Hero
|
5
|
+
attr_accessor :name, :id, :level, :hardcore, :gender, :last_updated, :dead
|
6
|
+
|
7
|
+
def initialize(server, btag, id, info=[])
|
8
|
+
|
9
|
+
@id = id
|
10
|
+
|
11
|
+
if info.empty?
|
12
|
+
|
13
|
+
btag.gsub!('#','-')
|
14
|
+
|
15
|
+
api_url = URI.escape("http://#{server}.battle.net/api/d3/profile/#{btag}/hero/#{id}")
|
16
|
+
ret = Net::HTTP.get(URI.parse(api_url))
|
17
|
+
info = JSON(ret)
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
@name = info['name']
|
22
|
+
@level = info['level']
|
23
|
+
@gender = info['gender']
|
24
|
+
@last_updated = info['last-updated']
|
25
|
+
@dead = info['dead']
|
26
|
+
@hardcore = info['hardcore']
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
require 'D3/hero'
|
5
|
+
|
6
|
+
class Diablo3
|
7
|
+
def initialize(server='us', btag)
|
8
|
+
|
9
|
+
@server = server
|
10
|
+
@btag = btag
|
11
|
+
|
12
|
+
@btag.gsub!('#','-')
|
13
|
+
api_url = URI.escape("http://#{@server}.battle.net/api/d3/profile/#{@btag}/")
|
14
|
+
ret = Net::HTTP.get(URI.parse(api_url))
|
15
|
+
@data = JSON(ret)
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_heroes
|
20
|
+
heroes = Hash.new
|
21
|
+
@data['heroes'].map do |h|
|
22
|
+
heroes[h['id']] = Hero.new(@server, @btag, h['id'], h)
|
23
|
+
end
|
24
|
+
|
25
|
+
heroes
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: diablo3-simple
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rodolfo Sikora
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-12 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: The main goal is to provide a simple class that fetches Diablo3 information
|
15
|
+
using Blizzard's official API.
|
16
|
+
email: sikora@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/diablo3-simple.rb
|
22
|
+
- lib/D3/hero.rb
|
23
|
+
homepage: http://rubygems.org/gems/diablo3-simple
|
24
|
+
licenses: []
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.24
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: A ruby gem to fetch Diablo 3 game information based on the server and battletag.
|
47
|
+
test_files: []
|