Class: RefererRecord
- Inherits:
-
Object
- Object
- RefererRecord
- Defined in:
- lib/RefererRecord.rb
Instance Attribute Summary collapse
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #addHit(hit) ⇒ Object
- #external? ⇒ Boolean
- #hitCount ⇒ Object
-
#initialize(url) ⇒ RefererRecord
constructor
A new instance of RefererRecord.
- #lastHit ⇒ Object
- #purge(deadline) ⇒ Object
Constructor Details
#initialize(url) ⇒ RefererRecord
Returns a new instance of RefererRecord.
18 19 20 21 |
# File 'lib/RefererRecord.rb', line 18 def initialize(url) @hits = [] @url = url end |
Instance Attribute Details
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
16 17 18 |
# File 'lib/RefererRecord.rb', line 16 def hits @hits end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
16 17 18 |
# File 'lib/RefererRecord.rb', line 16 def url @url end |
Instance Method Details
#addHit(hit) ⇒ Object
23 24 25 26 |
# File 'lib/RefererRecord.rb', line 23 def addHit(hit) @hits.push(hit) hit.referer = self end |
#external? ⇒ Boolean
43 44 45 |
# File 'lib/RefererRecord.rb', line 43 def external? return @url[0, 1] != '/' end |
#hitCount ⇒ Object
39 40 41 |
# File 'lib/RefererRecord.rb', line 39 def hitCount return @hits.length() end |
#lastHit ⇒ Object
47 48 49 |
# File 'lib/RefererRecord.rb', line 47 def lastHit return @hits[-1] end |
#purge(deadline) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/RefererRecord.rb', line 28 def purge(deadline) @hits.each do |h| if h.timeStamp < deadline @hits.delete(h) else return false end end @hits.empty? end |