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 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[:title]
9
- @long_url = attrs[:long_url]
10
- @short_url = attrs[:short_url]
11
- @kclicks = attrs[:kclicks]
12
- @date = attrs[:date]
13
- @award_id = attrs[:award_id]
14
- @award_img = attrs[:award_img]
15
- @award_desc = attrs[:award_desc]
16
- @others = attrs[:others]
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
 
@@ -1,3 +1,3 @@
1
1
  module RCracy
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
- kcys = []
20
+ http_response = Net::HTTP.get_response(URI.parse(request_url))
23
21
 
24
- result.each do |kcy|
22
+ hashed_kcys = JSON.parse(http_response.body)['data']['user'][0]['kcys']
25
23
 
26
- kcys.push(RCracy::Kcy.new(kcy))
24
+ kcys = []
27
25
 
28
- end
26
+ hashed_kcys.each { |hashed_kcy| kcys.push(RCracy::Kcy.new(hashed_kcy)) }
29
27
 
30
28
  return kcys
31
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcracy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: