Class: NameCheckerStrategy

Inherits:
GeneralStrategy show all
Defined in:
lib/burnspam/point_tracker.rb

Overview

A specialized strategy for analizing the name field. Analysis for name usually requires much less processing than comment body.

Version

0.1.1

Date

2011/12/18

@author

Brian Burns, x10205284

@reference

snook.ca/archives/other/effective_blog_comment_spam_blocker

Instance Method Summary collapse

Methods inherited from GeneralStrategy

#keywords, #test

Constructor Details

#initialize(name) ⇒ NameCheckerStrategy

Stores name as a string and value in array



177
178
179
180
# File 'lib/burnspam/point_tracker.rb', line 177

def initialize(name)
  @name = name
  @keywords = [name]    
end

Instance Method Details

#count_urlsObject

We only expect to count one or zero URLs in name



183
184
185
# File 'lib/burnspam/point_tracker.rb', line 183

def count_urls
  @name.include?('http://') ? 1 : 0
end

#duplicate?Boolean

This method is not used but must be included to interface correctly with the Checker class

Returns:

  • (Boolean)


205
206
207
# File 'lib/burnspam/point_tracker.rb', line 205

def duplicate?
  false
end

#lengthObject

Check length of name



193
194
195
# File 'lib/burnspam/point_tracker.rb', line 193

def length
  @name.length
end

#starts_with?Boolean

This method is not used but must be included to interface correctly with the Checker class

Returns:

  • (Boolean)


199
200
201
# File 'lib/burnspam/point_tracker.rb', line 199

def starts_with?
  false
end

#url_lengthObject

Check length if URL exists



188
189
190
# File 'lib/burnspam/point_tracker.rb', line 188

def url_length
  count_urls ? @name.length : 0
end