rcracy 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rcracy/kcy.rb +10 -10
- data/lib/rcracy/version.rb +1 -1
- data/lib/rcracy.rb +4 -6
- metadata +1 -1
data/lib/rcracy/kcy.rb
CHANGED
@@ -4,16 +4,16 @@ module RCracy
|
|
4
4
|
|
5
5
|
attr_reader :title, :long_url, :short_url, :kclicks, :date, :award_id, :award_img, :award_desc, :others
|
6
6
|
|
7
|
-
def initialize(attrs
|
8
|
-
@title = attrs[
|
9
|
-
@long_url = attrs[
|
10
|
-
@short_url = attrs[
|
11
|
-
@kclicks = attrs[
|
12
|
-
@date = attrs[
|
13
|
-
@award_id = attrs[
|
14
|
-
@award_img = attrs[
|
15
|
-
@award_desc = attrs[
|
16
|
-
@others = attrs[
|
7
|
+
def initialize(attrs)
|
8
|
+
@title = attrs['title']
|
9
|
+
@long_url = attrs['longurl']
|
10
|
+
@short_url = attrs['shorturl']
|
11
|
+
@kclicks = attrs['kclicks']
|
12
|
+
@date = attrs['date']
|
13
|
+
@award_id = attrs['awardId']
|
14
|
+
@award_img = attrs['awardImg']
|
15
|
+
@award_desc = attrs['awardDesc']
|
16
|
+
@others = attrs['others']
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
data/lib/rcracy/version.rb
CHANGED
data/lib/rcracy.rb
CHANGED
@@ -16,16 +16,14 @@ module RCracy
|
|
16
16
|
def get_kcys_from(username, from = 1, num = 10)
|
17
17
|
|
18
18
|
request_url = "#{API_BASE_URL}/user/#{username}?kcy=1&from=#{from}&num=#{num}&appkey=#{@app_key}"
|
19
|
-
response = Net::HTTP.get_response(URI.parse(request_url))
|
20
|
-
result = JSON.parse(response.body)['data']['user'][0]['kcys']
|
21
19
|
|
22
|
-
|
20
|
+
http_response = Net::HTTP.get_response(URI.parse(request_url))
|
23
21
|
|
24
|
-
|
22
|
+
hashed_kcys = JSON.parse(http_response.body)['data']['user'][0]['kcys']
|
25
23
|
|
26
|
-
|
24
|
+
kcys = []
|
27
25
|
|
28
|
-
|
26
|
+
hashed_kcys.each { |hashed_kcy| kcys.push(RCracy::Kcy.new(hashed_kcy)) }
|
29
27
|
|
30
28
|
return kcys
|
31
29
|
|