Class XhochY::Drossellog::DailyIPCounter
In: xhochy/drossellog/dailyipcounter.rb
Parent: Object
PageCounter EntryCounter ImpressionCounter DataCounter LogFileParser WeeklyReport CodeCounter MonthlyReport LogLine DailyReport DailyIPCounter IPCounter ImpressionBlacklist Drossellog XhochY dot/f_1.png

Counts the number of IP‘s and how much they‘ve surfed

Methods

add   from_hash   new   to_hash  

Attributes

users  [R]  The users(IP adresses) which made requests

Public Class methods

Creates a new IPCounter instance

[Source]

    # File xhochy/drossellog/dailyipcounter.rb, line 12
12:       def initialize
13:         @users = {
14:           'Sun' => IPCounter.new,
15:           'Mon' => IPCounter.new,
16:           'Tue' => IPCounter.new,
17:           'Wed' => IPCounter.new,
18:           'Thu' => IPCounter.new,
19:           'Fri' => IPCounter.new,
20:           'Sat' => IPCounter.new
21:         }
22:       end

Public Instance methods

Count another user, users are identified by their IP

[Source]

    # File xhochy/drossellog/dailyipcounter.rb, line 25
25:       def add(day, data)
26:         # we want the day as a string       
27:         if day.class == Fixnum
28:           day = Time::RFC2822_DAY_NAME[day]
29:         end
30:         
31:         if day != nil  
32:           @users[day].add data
33:         end
34:       end

import data from a Hash, overrides old data

[Source]

    # File xhochy/drossellog/dailyipcounter.rb, line 46
46:       def from_hash(data)
47:         @users = data.clone
48:       end

Return the data of this object as a hash

[Source]

    # File xhochy/drossellog/dailyipcounter.rb, line 37
37:       def to_hash
38:         ret = {}
39:         @users.each do |key, value|
40:           ret[key] = value.to_hash
41:         end
42:         ret
43:       end

[Validate]