Skip to content

Instantly share code, notes, and snippets.

@thiagoa
Created October 5, 2016 13:00
Show Gist options
  • Save thiagoa/0b89ba0763d24667c34127618b29f771 to your computer and use it in GitHub Desktop.
Save thiagoa/0b89ba0763d24667c34127618b29f771 to your computer and use it in GitHub Desktop.
TwitterTimelineHub first context
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