Module: Scrapbooker::Helpers::TweetHelpers

Included in:
Scrapbooker::Helpers
Defined in:
lib/scrapbooker/helpers/tweet_helpers.rb

Instance Method Summary collapse

Instance Method Details

#expand_hashtag(hashtag, tweet) ⇒ Object



14
15
16
# File 'lib/scrapbooker/helpers/tweet_helpers.rb', line 14

def expand_hashtag(hashtag,tweet)
  tweet.sub!("#{hashtag}", link_to(hashtag,"http://twitter.com/search/#{URI.escape(hashtag)}",:target => :blank))
end


18
19
20
# File 'lib/scrapbooker/helpers/tweet_helpers.rb', line 18

def expand_link(link,tweet)
  tweet.sub!(link['display'], link_to(link['source'],link['source'],:target => :blank))
end

#expand_media(media, tweet) ⇒ Object



22
23
24
# File 'lib/scrapbooker/helpers/tweet_helpers.rb', line 22

def expand_media(media,tweet)
  tweet.sub!(media['display'], link_to(media['source'],media['source'],:target => :blank))
end

#expand_mention(mention, tweet) ⇒ Object



26
27
28
# File 'lib/scrapbooker/helpers/tweet_helpers.rb', line 26

def expand_mention(mention,tweet)
  tweet.sub!(/@#{mention}/i, link_to("@#{mention}","http://twitter.com/#{mention}",:target => :blank))
end

#render_tweet(tweet) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/scrapbooker/helpers/tweet_helpers.rb', line 5

def render_tweet(tweet)
  rendered_tweet = tweet.entry
tweet.hashtags.each { |hashtag| expand_hashtag(hashtag,rendered_tweet) }
tweet.mentions.each { |mention| expand_mention(mention,rendered_tweet) }
tweet.links.each { |link| expand_link(link,rendered_tweet) }
tweet.media.each { |media| expand_media(media,rendered_tweet) }
  return raw rendered_tweet
end