Sha256: 28d1da674d5fa5a21618eb66e0f271a9e57831f7995b0126524736c9bc516fd2
Contents?: true
Size: 834 Bytes
Versions: 3
Compression:
Stored size: 834 Bytes
Contents
require 'action_view' require 'rinku' module Stratify module Twitter class Presenter include ActionView::Helpers::UrlHelper def initialize(activity) @activity = activity end def text return @activity.text unless @activity.retweet? "RT @#{@activity.retweeted_status['username']} #{@activity.retweeted_status['text']}" end def to_html linkify_usernames(linkify_urls(text)) end private def linkify_urls(text) Rinku.auto_link(text) end def linkify_usernames(text) text.gsub(/@\w*\b/) do |username| username_without_at_sign = username.delete("@") username_url = "http://twitter.com/#{username_without_at_sign}" link_to username, username_url end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stratify-twitter-0.1.5 | lib/stratify-twitter/presenter.rb |
stratify-twitter-0.1.4.1 | lib/stratify-twitter/presenter.rb |
stratify-twitter-0.1.4 | lib/stratify-twitter/presenter.rb |