class SirTrevorRails::Blocks::TweetBlock

Public Instance Methods

at_name() click to toggle source
# File lib/sir_trevor_rails/blocks/tweet_block.rb, line 24
def at_name
  "@" << screen_name
end
profile_image_url() click to toggle source
# File lib/sir_trevor_rails/blocks/tweet_block.rb, line 28
def profile_image_url
  # TODO: add support for different size images: https://dev.twitter.com/overview/general/user-profile-images-and-banners

  # Split the URL to omit the protocol and let the browser define the context (note: assumes asset is available over both HTTP and HTTPS)
  "//" << self.user[:profile_image_url].split("://")[1]
end
profile_url() click to toggle source
# File lib/sir_trevor_rails/blocks/tweet_block.rb, line 16
def profile_url
  "//twitter.com/" << self.user[:screen_name]
end
render_tweet_body() click to toggle source
# File lib/sir_trevor_rails/blocks/tweet_block.rb, line 9
def render_tweet_body
  sanitize Twitter::Autolink.auto_link(
        self.text,
        url_entities: (self.entities.values_at(:urls, :media).flatten.compact.uniq rescue nil)
      ), tags: %w{a span}, attributes: %w{class href rel target}
end
screen_name() click to toggle source
# File lib/sir_trevor_rails/blocks/tweet_block.rb, line 20
def screen_name
  self.user[:screen_name]
end