Class: MarkovTwitter::TweetReader

Inherits:
Object
  • Object
show all
Defined in:
lib/markov_twitter/tweet_reader.rb

Overview

Fetches the latest tweets.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ TweetReader

Returns a new instance of TweetReader.

Parameters:

  • client (Twitter::REST::Client)


8
9
10
# File 'lib/markov_twitter/tweet_reader.rb', line 8

def initialize(client:)
  @client = client
end

Instance Attribute Details

#clientTwitter::REST::Client (readonly)

Returns:

  • (Twitter::REST::Client)


5
6
7
# File 'lib/markov_twitter/tweet_reader.rb', line 5

def client
  @client
end

Instance Method Details

#get_tweets(username:) ⇒ Array<Hash>

Returns - the hashes will have :text and :id keys.

Parameters:

  • username (String)

    must exist om twitter or this will raise an error

Returns:

  • (Array<Hash>)
    • the hashes will have :text and :id keys



15
16
17
18
# File 'lib/markov_twitter/tweet_reader.rb', line 15

def get_tweets(username:)
  user = client.user(username)
  client.user_timeline(user)
end