Class: RandomComposer
- Defined in:
- lib/composers/random_composer.rb
Instance Method Summary collapse
- #compose_image_query(query) ⇒ Object
- #compose_tweet ⇒ Object
-
#initialize(config, twitter_client, tweet_finder, emoji_finder) ⇒ RandomComposer
constructor
A new instance of RandomComposer.
Constructor Details
#initialize(config, twitter_client, tweet_finder, emoji_finder) ⇒ RandomComposer
Returns a new instance of RandomComposer.
6 7 8 |
# File 'lib/composers/random_composer.rb', line 6 def initialize(config, twitter_client, tweet_finder, emoji_finder) super(config, twitter_client, tweet_finder, emoji_finder) end |
Instance Method Details
#compose_image_query(query) ⇒ Object
23 24 25 |
# File 'lib/composers/random_composer.rb', line 23 def compose_image_query(query) find_random_word(query) end |
#compose_tweet ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/composers/random_composer.rb', line 10 def compose_tweet tweets = @tweet_finder.find_tweets tweets = tweets.map { |t| normalize(t) } hashtag = find_random_word(tweets.sample) emoji = @emoji_finder.find text = tweets.join([', ', ' - ', '! '].sample) text = filter(text) text = trim(text, hashtag.length) text = replace_a_word(text.split.sample, text) text = replace_a_word(emoji, text) Tweet.new(text.capitalize, hashtag, @twitter_client) end |