rb/lib/twitter-text/extractor.rb
# Extracts a list of all usernames mentioned in the Tweet <tt>text</tt>
# along with the indices for where the mention ocurred.  If the
# <tt>text</tt> is nil or contains no username mentions, an empty array
# will be returned.
#
# If a block is given, then it will be called with each username, the start
# index, and the end index in the <tt>text</tt>.
Extracts a list of all usernames mentioned in the Tweet text
along with the indices for where the mention ocurred.  If the
text is nil or contains no username mentions, an empty array
will be returned.

If a block is given, then it will be called with each username, the start
index, and the end index in the text.
Extracts a list of all usernames mentioned in the Tweet text along with the indices for where the mention ocurred . If the text is nil or contains no username mentions an empty array will be returned . If a block is given then it will be called with each username the start index and the end index in the text .
def extract_mentioned_screen_names_with_indices(text) 
        return [] unless text
        possible_screen_names = []
        extract_mentions_or_lists_with_indices(text) do |screen_name, list_slug, start_position, end_position|
          next unless list_slug.empty?
          possible_screen_names << {
            :screen_name => screen_name,
            :indices => [start_position, end_position]
          }
        end
        if block_given?
          possible_screen_names.each do |mention|
            yield mention[:screen_name], mention[:indices].first, mention[:indices].last
          end
        end
        possible_screen_names
      end
def extract_mentioned_screen_names_with_indices ( text ) return [ ] unless text possible_screen_names = [ ] extract_mentions_or_lists_with_indices ( text ) do | screen_name , list_slug , start_position , end_position | next unless list_slug . empty? possible_screen_names << { :screen_name => screen_name , :indices => [ start_position , end_position ] } end if block_given? possible_screen_names . each do | mention | yield mention [ :screen_name ] , mention [ :indices ] . first , mention [ :indices ] . last end end possible_screen_names end
Extracts a list of all usernames mentioned in the Tweet <tt>text</tt>
along with the indices for where the mention ocurred.
Extracts a list of all usernames mentioned in the Tweet <tt > text< / tt > along with the indices for where the mention ocurred .
# :yields: username, start, end
text
<not_specific>