module Quesadilla::Extractor::Hashtags

Extract hashtags.

This module has no public methods.

Private Instance Methods

extract_hashtags() click to toggle source
# File lib/quesadilla/extractor/hashtags.rb, line 13
def extract_hashtags
  Twitter::Extractor::extract_hashtags_with_indices(@working_text).each do |entity|
    hashtag = entity[:hashtag]

    # Validate
    if validator = @options[:hashtag_validator]
      next unless validator.call(hashtag)
    end

    display_text = "##{hashtag}"
    @entities << {
      type: ENTITY_TYPE_HASHTAG,
      text: display_text,
      display_text: display_text,
      indices: entity[:indices],
      hashtag: hashtag.downcase
    }
    @working_text.sub!(display_text, REPLACE_TOKEN * display_text.length)
  end
end