module Trumptweets

Main module for getting trump tweets

Constants

VERSION

Public Class Methods

fake_news() click to toggle source

Get a random tweet of trump mentioning the phrase fake news

# File lib/trumptweets.rb, line 24
def self.fake_news()
        get_tweet('fake_news')
end
hilary() click to toggle source

Get a random tweet of trump mentioning Hilary or Clinton

# File lib/trumptweets.rb, line 34
def self.hilary()
        get_tweet('hilary')
end
maga() click to toggle source

Get a random tweet of trump mentioning the term MAGA

# File lib/trumptweets.rb, line 39
def self.maga()
        get_tweet('maga')
end
obama() click to toggle source

Get a random tweet of trump mentioning Obama

# File lib/trumptweets.rb, line 44
def self.obama()
        get_tweet('obama')
end
russia() click to toggle source

Get a random tweet of trump mentioning Russia

# File lib/trumptweets.rb, line 29
def self.russia()
        get_tweet('russia')
end
tweet() click to toggle source

Gets a random trump tweet from his time of presidency

# File lib/trumptweets.rb, line 19
def self.tweet()
        get_tweet(@tweet_mapping.keys.sample)
end

Private Class Methods

get_random_index(arr_length) click to toggle source

Gets a random index number

# File lib/trumptweets.rb, line 62
def self.get_random_index(arr_length)
        rand(0..arr_length)
end
get_tweet(type) click to toggle source

Logic to pull the tweets from the other modules with a list of their respective types i.e. maga tweets / hilary tweets

# File lib/trumptweets.rb, line 52
def self.get_tweet(type)
        if !type
                raise 'No type of tweet was specific'
        end

        random_number = get_random_index(@tweet_mapping[type.to_sym].length)
        @tweet_mapping[type.to_sym][random_number]
end