Created
October 5, 2016 13:00
-
-
Save thiagoa/0b89ba0763d24667c34127618b29f771 to your computer and use it in GitHub Desktop.
TwitterTimelineHub first context
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwitterTimelineHub | |
Result = Struct.new(:status, :tweets) | |
def initialize(twitter_client = TwitterClientFactory.new.call) | |
@twitter_client = twitter_client | |
end | |
def call(user, count: 20) | |
tweets = @twitter_client.user_timeline(user, count: count).map do |tweet| | |
{ created_at: tweet.created_at, | |
screen_name: tweet.user.screen_name, | |
text: tweet.text, | |
mentions: tweet.user_mentions.map(&:screen_name) } | |
end | |
Result.new(:ok, tweets) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment