Class: VisitorRecord
- Inherits:
-
Object
- Object
- VisitorRecord
- Defined in:
- lib/VisitorRecord.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#firstHit ⇒ Object
readonly
Returns the value of attribute firstHit.
-
#firstPage ⇒ Object
readonly
Returns the value of attribute firstPage.
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#lastHit ⇒ Object
readonly
Returns the value of attribute lastHit.
-
#lastPage ⇒ Object
readonly
Returns the value of attribute lastPage.
-
#pageCount ⇒ Object
readonly
Returns the value of attribute pageCount.
-
#robot ⇒ Object
Returns the value of attribute robot.
Instance Method Summary collapse
- #addHit(hit) ⇒ Object
- #bytes ⇒ Object
- #city ⇒ Object
- #country ⇒ Object
- #hitCount ⇒ Object
- #host ⇒ Object
-
#initialize(ip, browser) ⇒ VisitorRecord
constructor
A new instance of VisitorRecord.
- #purge(deadline) ⇒ Object
- #referer ⇒ Object
Constructor Details
#initialize(ip, browser) ⇒ VisitorRecord
Returns a new instance of VisitorRecord.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/VisitorRecord.rb', line 21 def initialize(ip, browser) @hits = [] @ip = ip @firstHit = nil @lastHit = nil @firstPage = nil @lastPage = nil @browser = browser @pageCount = 0 @robot = nil end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def browser @browser end |
#firstHit ⇒ Object (readonly)
Returns the value of attribute firstHit.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def firstHit @firstHit end |
#firstPage ⇒ Object (readonly)
Returns the value of attribute firstPage.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def firstPage @firstPage end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def hits @hits end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def ip @ip end |
#lastHit ⇒ Object (readonly)
Returns the value of attribute lastHit.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def lastHit @lastHit end |
#lastPage ⇒ Object (readonly)
Returns the value of attribute lastPage.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def lastPage @lastPage end |
#pageCount ⇒ Object (readonly)
Returns the value of attribute pageCount.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def pageCount @pageCount end |
#robot ⇒ Object
Returns the value of attribute robot.
17 18 19 |
# File 'lib/VisitorRecord.rb', line 17 def robot @robot end |
Instance Method Details
#addHit(hit) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/VisitorRecord.rb', line 33 def addHit(hit) @firstHit = hit if @firstHit == nil @lastHit = hit @hits.push(hit) hit.visitor = self if hit.page.isPage # Remove old exit page flag from previous last page @lastPage.exit = false if @lastPage hit.exit = true @pageCount += 1 if @firstPage == nil @firstPage = hit hit.entry = true end @lastPage = hit end end |
#bytes ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/VisitorRecord.rb', line 71 def bytes bytes = 0 @hits.each do |h| bytes += h.bytes end return bytes end |
#city ⇒ Object
90 91 92 |
# File 'lib/VisitorRecord.rb', line 90 def city $geoLocator.city(ip) end |
#country ⇒ Object
86 87 88 |
# File 'lib/VisitorRecord.rb', line 86 def country $geoLocator.country(ip) end |
#hitCount ⇒ Object
67 68 69 |
# File 'lib/VisitorRecord.rb', line 67 def hitCount return @hits.length() end |
#host ⇒ Object
63 64 65 |
# File 'lib/VisitorRecord.rb', line 63 def host return $resolver.hostName(@ip) end |
#purge(deadline) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/VisitorRecord.rb', line 52 def purge(deadline) @hits.each do |h| if h.timeStamp < deadline @hits.delete(h) else return false end end @hits.empty? end |
#referer ⇒ Object
79 80 81 82 83 84 |
# File 'lib/VisitorRecord.rb', line 79 def referer @hits.each do |h| return h.referer if h.referer != nil && h.referer.external? end return nil end |