Class: Nfcollector::Categoriser::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/nfcollector/categoriser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEntry

Returns a new instance of Entry.



8
9
10
11
12
# File 'lib/nfcollector/categoriser.rb', line 8

def initialize
  @hits       = 0
  @last_seen  = Time.at(0)
  @categories = Set.new
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



6
7
8
# File 'lib/nfcollector/categoriser.rb', line 6

def categories
  @categories
end

#hitsObject (readonly)

Returns the value of attribute hits.



5
6
7
# File 'lib/nfcollector/categoriser.rb', line 5

def hits
  @hits
end

#last_seenObject (readonly)

Returns the value of attribute last_seen.



4
5
6
# File 'lib/nfcollector/categoriser.rb', line 4

def last_seen
  @last_seen
end

Instance Method Details

#update(last_seen, category_ids) ⇒ Object



14
15
16
17
18
# File 'lib/nfcollector/categoriser.rb', line 14

def update(last_seen, category_ids)
  @hits += 1
  @last_seen = last_seen if @last_seen < last_seen
  @categories.merge(category_ids)
end