Module: TweetSanitizer::TwitterExtension

Defined in:
lib/tweet_sanitizer/twitter_extension.rb

Instance Method Summary collapse

Instance Method Details

#sanitized_text(use_retweeted_tweet: true, expand_url: true, remove_media_url: true, unescape: true) ⇒ String

Sanitize tweet

Parameters:

  • use_retweeted_tweet (Boolean) (defaults to: true)

    Whether use original retweeted tweet if exists

  • expand_url (Boolean) (defaults to: true)

    Whether expand url in tweet (e.g. t.co url -> original url)

  • remove_media_url (Boolean) (defaults to: true)

    Whether remove media url in tweet

  • unescape (Boolean) (defaults to: true)

    Whether unescape in tweet (e.g. (&gt; &lt;) -> (> <))

Returns:

  • (String)


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tweet_sanitizer/twitter_extension.rb', line 14

refine(Twitter::Tweet) do
  def sanitized_text(use_retweeted_tweet: true, expand_url: true, remove_media_url: true, unescape: true)
    TweetSanitizer.sanitize(
      self,
      use_retweeted_tweet: use_retweeted_tweet,
      expand_url:          expand_url,
      remove_media_url:    remove_media_url,
      unescape:            unescape,
    )
  end
end