Class: Ping::Mention
- Inherits:
-
Object
- Object
- Ping::Mention
- Defined in:
- lib/ping/mention.rb
Constant Summary collapse
- PATTERN =
/ (?:^|\W) # beginning of string or non-word char @((?>[a-z0-9][a-z0-9-]*)) # @username (?!\/) # without a trailing slash (?= \.+[ \t]| # dots followed by space or non-word character \.+$| # dots at end of line [^0-9a-zA-Z_.]| # non-word character except dot $ # end of line ) /ix
Instance Attribute Summary collapse
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #==(username) ⇒ Object
-
#initialize(username) ⇒ Mention
constructor
A new instance of Mention.
- #to_s ⇒ Object
Constructor Details
#initialize(username) ⇒ Mention
Returns a new instance of Mention.
17 18 19 |
# File 'lib/ping/mention.rb', line 17 def initialize(username) @username = username end |
Instance Attribute Details
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/ping/mention.rb', line 3 def username @username end |
Class Method Details
.extract(text) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ping/mention.rb', line 21 def self.extract(text) text.scan(PATTERN).flatten .map(&:downcase).uniq.map do |username| new(username) end end |
Instance Method Details
#==(username) ⇒ Object
28 29 30 |
# File 'lib/ping/mention.rb', line 28 def ==(username) username == self.username end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/ping/mention.rb', line 32 def to_s username end |