lib/usaidwat/service.rb in usaidwat-1.3.0 vs lib/usaidwat/service.rb in usaidwat-1.4.0
- old
+ new
@@ -14,10 +14,22 @@
@ups = data['ups']
@downs = data['downs']
end
end
+ class MockSubmission
+ attr_reader :subreddit, :title, :created_utc, :permalink
+
+ def initialize(dict)
+ data = dict['data']
+ @subreddit = data['subreddit']
+ @title = data['title']
+ @created_utc = data['created_utc']
+ @permalink = data['permalink']
+ end
+ end
+
class MockUser
def initialize(username)
@username = username
end
@@ -26,9 +38,14 @@
end
def comments(n)
json = load_data("#{@username}.json")
json['data']['children'].map { |d| MockComment.new(d) }
+ end
+
+ def posts
+ json = load_data("submissions_#{@username}.json")
+ json['data']['children'].map { |d| MockSubmission.new(d) }
end
private
def load_data(data_file)