class LastTweet::TwitterAccount

Attributes

bio[RW]
handle[RW]
name[RW]
tweets[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/last_tweet/twitter_account.rb, line 5
def self.all
  @@all
end
create_from_handle(t_handle) click to toggle source
# File lib/last_tweet/twitter_account.rb, line 9
def self.create_from_handle(t_handle)
  unless all.any?{|acct| acct.handle == t_handle}
    account        = new
    account.handle = t_handle
    account.url    = "https://twitter.com/" + t_handle[1..-1]

    name_qry       = ["div.ProfileHeaderCard h1.ProfileHeaderCard-name a.ProfileHeaderCard-nameLink", "text", "method"]
    bio_qry        = ["div.ProfileHeaderCard p.ProfileHeaderCard-bio", "text", "method"]
    what_to_scrape = {name: name_qry, bio: bio_qry}
    twitter_hash   = LastTweet::Scraper.scrape(account.url, what_to_scrape)

    account.name   = twitter_hash[:name]
    account.bio    = twitter_hash[:bio]
    account.tweets = []

    @@all << account
  end
  all.detect{|acct| acct.handle == t_handle}
end

Public Instance Methods

remove() click to toggle source
# File lib/last_tweet/twitter_account.rb, line 39
def remove
  @@all.delete(self)
end