Sha256: 27dc4a60906b6cf4f7249c968f6accbb4c1aa6c8335c6ca43982f87a117bd50e
Contents?: true
Size: 842 Bytes
Versions: 3
Compression:
Stored size: 842 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.3 | lib/stratify-twitter/presenter.rb |
stratify-twitter-0.1.2 | lib/stratify-twitter/presenter.rb |
stratify-twitter-0.1.1 | lib/stratify-twitter/presenter.rb |