module StringSurgeon::Clamp

Constants

ATMENTION_REG_EX
HASHTAG_REG_EX

Public Instance Methods

all_atmentions(str) click to toggle source
# File lib/string_surgeon/clamp.rb, line 26
def all_atmentions(str)
  names = []
  sanitize_links(str).scan(ATMENTION_REG_EX) do
    names << $&
  end
  names
end
all_hashtags(str) click to toggle source
# File lib/string_surgeon/clamp.rb, line 7
def all_hashtags(str)
  tags = []
  sanitize_links(str).scan(HASHTAG_REG_EX) do
    tags << $&
  end
  tags
end
unique_atmentions(str) click to toggle source
# File lib/string_surgeon/clamp.rb, line 34
def unique_atmentions(str)
  names = []
  all_names = []
  return names if(str.empty?)
  sanitize_links(str).scan(ATMENTION_REG_EX) do
    names << $& unless all_names.include?($&.downcase)
    all_names << $&.downcase
  end
  names
end
unique_hashtags(str) click to toggle source
# File lib/string_surgeon/clamp.rb, line 15
def unique_hashtags(str)
  tags = []
  all_tags = []
  return tags if(str.empty?)
  sanitize_links(str).scan(HASHTAG_REG_EX) do
    tags << $& unless all_tags.include?($&.downcase)
    all_tags << $&.downcase
  end
  tags
end