Module: Scrapbooker::Services::TweetMethods

Included in:
Scrapbooker::Services
Defined in:
lib/scrapbooker/services/twitter_feed.rb

Instance Method Summary collapse

Instance Method Details

#hashtagsObject



102
103
104
105
106
107
108
109
110
# File 'lib/scrapbooker/services/twitter_feed.rb', line 102

def hashtags
  hashtags = Array.new
  if self.original_tweet['entities'] && self.original_tweet['entities']['hashtags']
    for hashtag in self.original_tweet['entities']['hashtags'] do
      hashtags << "##{hashtag['text']}"
    end
  end
  return hashtags
end

#is_retweetObject



66
67
68
# File 'lib/scrapbooker/services/twitter_feed.rb', line 66

def is_retweet
  self.original_tweet['retweeted_status'] ? true : false
end


70
71
72
73
74
75
76
77
78
79
# File 'lib/scrapbooker/services/twitter_feed.rb', line 70

def links
  links = Array.new
  if self.original_tweet['entities'] && self.original_tweet['entities']['urls']
    for link in self.original_tweet['entities']['urls'] do
      link_hash = Hash['source', link['expanded_url'], 'display', link['url']] 
      links << link_hash
    end
  end
  return links
end

#mediaObject



81
82
83
84
85
86
87
88
89
90
# File 'lib/scrapbooker/services/twitter_feed.rb', line 81

def media
  media = Array.new
  if self.original_tweet['entities'] && self.original_tweet['entities']['media']
    for entity in self.original_tweet['entities']['media'] do
      media_hash = Hash['source', entity['media_url'], 'display', entity['url'], 'type', entity['type']]
      media << media_hash
    end
  end
  return media
end

#mentionsObject



92
93
94
95
96
97
98
99
100
# File 'lib/scrapbooker/services/twitter_feed.rb', line 92

def mentions
  mentions = Array.new
  if self.original_tweet['entities'] && self.original_tweet['entities']['user_mentions']
    for mention in self.original_tweet['entities']['user_mentions'] do
      mentions << "#{mention['screen_name']}"
    end
  end
  return mentions
end

#original_tweetObject



62
63
64
# File 'lib/scrapbooker/services/twitter_feed.rb', line 62

def original_tweet
  YAML::load(self.raw_feed)
end