Class: StopForumSpam::Spammer
- Inherits:
-
Object
- Object
- StopForumSpam::Spammer
- Defined in:
- lib/stop_forum_spam/spammer.rb
Instance Attribute Summary collapse
-
#appears ⇒ Object
(also: #appears?)
readonly
Returns the value of attribute appears.
-
#frequency ⇒ Object
(also: #count)
readonly
Returns the value of attribute frequency.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_seen ⇒ Object
readonly
Returns the value of attribute last_seen.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id) ⇒ Spammer
constructor
A new instance of Spammer.
Constructor Details
#initialize(id) ⇒ Spammer
Returns a new instance of Spammer.
8 9 10 11 12 13 14 |
# File 'lib/stop_forum_spam/spammer.rb', line 8 def initialize(id) @id = id @type = self.class.guess_type(id) @frequency = response["frequency"] @last_seen = response["lastseen"] @appears = response['appears'] == 'yes' ? true : false end |
Instance Attribute Details
#appears ⇒ Object (readonly) Also known as: appears?
Returns the value of attribute appears.
3 4 5 |
# File 'lib/stop_forum_spam/spammer.rb', line 3 def appears @appears end |
#frequency ⇒ Object (readonly) Also known as: count
Returns the value of attribute frequency.
3 4 5 |
# File 'lib/stop_forum_spam/spammer.rb', line 3 def frequency @frequency end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/stop_forum_spam/spammer.rb', line 3 def id @id end |
#last_seen ⇒ Object (readonly)
Returns the value of attribute last_seen.
3 4 5 |
# File 'lib/stop_forum_spam/spammer.rb', line 3 def last_seen @last_seen end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/stop_forum_spam/spammer.rb', line 3 def type @type end |
Class Method Details
.guess_type(id) ⇒ Object
20 21 22 23 24 |
# File 'lib/stop_forum_spam/spammer.rb', line 20 def self.guess_type(id) return 'ip' if id.match(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/) return 'email' if id.match(/.*@.*/) return 'username' end |
.is_spammer?(id) ⇒ Boolean
16 17 18 |
# File 'lib/stop_forum_spam/spammer.rb', line 16 def self.is_spammer?(id) new(id).appears? end |