jugyo-rubytter 0.2.2 → 0.3.0

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.
@@ -10,5 +10,5 @@ end
10
10
 
11
11
  client = Rubytter.new(ARGV[0], ARGV[1])
12
12
  client.friends_timeline().each do |status|
13
- puts "#{status['user']['screen_name']}: #{status['text']}"
13
+ puts "#{status.user.screen_name}: #{status.text}"
14
14
  end
data/lib/rubytter.rb CHANGED
@@ -4,6 +4,7 @@ require 'net/https'
4
4
  require 'cgi'
5
5
 
6
6
  require 'rubytter/connection'
7
+ require 'rubytter/hash_extension'
7
8
 
8
9
  class Rubytter
9
10
  APP_NAME = self.to_s
@@ -76,7 +77,21 @@ class Rubytter
76
77
  res_text = @connection.start(@host) do |http|
77
78
  http.request(req).body
78
79
  end
79
- return JSON.parse(res_text)
80
+ json = JSON.parse(res_text)
81
+ return case json
82
+ when Array
83
+ json.map do |i|
84
+ if i.is_a?(Hash)
85
+ i.to_struct
86
+ else
87
+ i
88
+ end
89
+ end
90
+ when Hash
91
+ json.to_struct
92
+ else
93
+ json
94
+ end
80
95
  end
81
96
 
82
97
  def post(path, params = {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jugyo-rubytter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo