Class: Andeltsa::TwitterRequest

Inherits:
Object
  • Object
show all
Includes:
Connection, Helper
Defined in:
lib/andeltsa.rb

Overview

Your code goes here…

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

display_ranking, exit_message, rank_words, remove_stop_words, sort_hash_descend, words_counter

Methods included from Connection

check_connection, tweets_request

Constructor Details

#initialize(username, date) ⇒ TwitterRequest

Returns a new instance of TwitterRequest.



13
14
15
16
17
18
19
# File 'lib/andeltsa.rb', line 13

def initialize(username, date)
  @username = username
  @date = date
  @tweets_words = tweet_collect
  @okay_words = Helper.remove_stop_words(tweets_words)
  @words_rank = Helper.rank_words(okay_words)
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



12
13
14
# File 'lib/andeltsa.rb', line 12

def date
  @date
end

#okay_wordsObject

Returns the value of attribute okay_words.



12
13
14
# File 'lib/andeltsa.rb', line 12

def okay_words
  @okay_words
end

#tweets_wordsObject

Returns the value of attribute tweets_words.



12
13
14
# File 'lib/andeltsa.rb', line 12

def tweets_words
  @tweets_words
end

#usernameObject

Returns the value of attribute username.



12
13
14
# File 'lib/andeltsa.rb', line 12

def username
  @username
end

#words_rankObject

Returns the value of attribute words_rank.



12
13
14
# File 'lib/andeltsa.rb', line 12

def words_rank
  @words_rank
end

Instance Method Details

#count_words_in_tweetObject



31
32
33
# File 'lib/andeltsa.rb', line 31

def count_words_in_tweet
  Helper.words_counter
end

#tweet_collectObject



21
22
23
24
25
26
27
28
29
# File 'lib/andeltsa.rb', line 21

def tweet_collect
  Connection.tweets_request(username, date)
  tweets_only = File.open("./tweets_only_#{username}.json", "r")
  tweets_words = []
  tweets_only.each do |tweet|
    tweets_words << tweet
  end
  tweets_words.join(" ").split(/[^a-zA-Z]/)
end