On Tue, Feb 3, 2009 at 6:16 PM, Stuart Clarke
<stuart.clarke1986 / gmail.com> wrote:

> Ok I will get straight to the code causing the problem, so first off you
> need to no that 'eventdateID' is an array full of values taken from log
> files. A sample of the values in this array are:
>
>> MonFeb0220091
>> MonFeb0220091
>> MonFeb0220091
>> MonFeb0220091
>> MonFeb0220091
>> MonFeb0220091
>> WedAug062008
>> WedAug062008
>
>
> Then I have the following code:
>
>>> counts = Hash.new(0)
>>> eventdateID.each {|d| counts[d] +=1}
>>> counts.each do |d,cnt|
>>>    @alerts.push("#{event.event_id} #{@tab} #{event.time_written}
>>> #{@tab}#{event.event_type} #{@tab} #{type}") if cnt >= 5
>>> end

> Another test was:
>
> eventdateID.each {|d| counts[d] +=1}
> counts.each do |d,cnt|
> @alerts.push cnt
>
> This gives
>
> 1
> 1
> 1
> 1
> 1
> 1
> 1
>

Sorry Stuart, can you show the exact code that produces that output
(including the puts that you are using to print those values)? Cause
this works for me as it is:


irb(main):009:0> eventDateID = %w{MonFeb0220091 MonFeb0220091
MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 WedAug062008
WedAug062008}
=> ["MonFeb0220091", "MonFeb0220091", "MonFeb0220091",
"MonFeb0220091", "MonFeb0220091", "MonFeb0220091", "WedAug062008",
"WedAug062008"]
irb(main):010:0> counts = Hash.new(0)
=> {}
irb(main):011:0> eventDateID.each {|d| counts[d] += 1}
=> ["MonFeb0220091", "MonFeb0220091", "MonFeb0220091",
"MonFeb0220091", "MonFeb0220091", "MonFeb0220091", "WedAug062008",
"WedAug062008"]
irb(main):012:0> counts
=> {"MonFeb0220091"=>6, "WedAug062008"=>2}
irb(main):013:0> @alerts = []
=> []
irb(main):014:0> counts.each do |id, cnt|
irb(main):015:1* @alerts.push(id) if cnt >= 5
irb(main):016:1> end
=> {"MonFeb0220091"=>6, "WedAug062008"=>2}
irb(main):017:0> @alerts
=> ["MonFeb0220091"]


If each element in the array eventDateID is stored in the hash as a
different key (which is what seems to be happening), maybe what is
inside the array are not strings, but another class that has a
different implementation of eql?.
Can you inspect the eventDateID array to check that?

Jesus.