Class: PageRecord
- Inherits:
-
Object
- Object
- PageRecord
- Defined in:
- lib/PageRecord.rb
Instance Attribute Summary collapse
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#isPage ⇒ Object
readonly
Returns the value of attribute isPage.
-
#nextPages ⇒ Object
readonly
Returns the value of attribute nextPages.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #addHit(hit) ⇒ Object
- #addReferral(nextPage) ⇒ Object
- #entryCount ⇒ Object
- #exitCount ⇒ Object
- #hitCount ⇒ Object
-
#initialize(url, isPage) ⇒ PageRecord
constructor
A new instance of PageRecord.
- #lastHit ⇒ Object
- #purge(deadline) ⇒ Object
- #purgeNextPages(pages) ⇒ Object
Constructor Details
#initialize(url, isPage) ⇒ PageRecord
Returns a new instance of PageRecord.
18 19 20 21 22 23 |
# File 'lib/PageRecord.rb', line 18 def initialize(url, isPage) @hits = [] @nextPages = {} @url = url @isPage = isPage end |
Instance Attribute Details
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
16 17 18 |
# File 'lib/PageRecord.rb', line 16 def hits @hits end |
#isPage ⇒ Object (readonly)
Returns the value of attribute isPage.
16 17 18 |
# File 'lib/PageRecord.rb', line 16 def isPage @isPage end |
#nextPages ⇒ Object (readonly)
Returns the value of attribute nextPages.
16 17 18 |
# File 'lib/PageRecord.rb', line 16 def nextPages @nextPages end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
16 17 18 |
# File 'lib/PageRecord.rb', line 16 def url @url end |
Instance Method Details
#addHit(hit) ⇒ Object
25 26 27 28 |
# File 'lib/PageRecord.rb', line 25 def addHit(hit) @hits.push(hit) hit.page = self end |
#addReferral(nextPage) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/PageRecord.rb', line 49 def addReferral(nextPage) if nextPages.has_key?(nextPage) nextPages[nextPage] += 1 else nextPages[nextPage] = 1 end end |
#entryCount ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/PageRecord.rb', line 57 def entryCount count = 0 @hits.each do |h| count += 1 if h.entry end return count end |
#exitCount ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/PageRecord.rb', line 65 def exitCount count = 0 @hits.each do |h| count+= 1 if h.exit end return count end |
#hitCount ⇒ Object
45 46 47 |
# File 'lib/PageRecord.rb', line 45 def hitCount return @hits.length() end |
#lastHit ⇒ Object
73 74 75 |
# File 'lib/PageRecord.rb', line 73 def lastHit return @hits[-1] end |
#purge(deadline) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/PageRecord.rb', line 30 def purge(deadline) @hits.each do |h| if h.timeStamp < deadline @hits.delete(h) else return false end end @hits.empty? end |
#purgeNextPages(pages) ⇒ Object
41 42 43 |
# File 'lib/PageRecord.rb', line 41 def purgeNextPages(pages) pages.each { |p| @nextPages.delete(p) } end |