13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/ruby_reddit_api/json_listing.rb', line 13
def parse(json)
results = []
if json.is_a?(Array)
json.each do |j|
results << parse(j)
end
else
data = json["data"]
Reddit::Base.instance_variable_set("@modhash", data["modhash"])
children = data["children"] || [{"data" => data, "kind" => json["kind"] }]
children.each do |message|
kind = message["kind"]
message["data"]["kind"] = kind
results << self.new(message["data"])
end
end
return results.flatten
end
|