Class: Nfcollector::Categoriser::Entry
- Inherits:
-
Object
- Object
- Nfcollector::Categoriser::Entry
- Defined in:
- lib/nfcollector/categoriser.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#last_seen ⇒ Object
readonly
Returns the value of attribute last_seen.
Instance Method Summary collapse
-
#initialize ⇒ Entry
constructor
A new instance of Entry.
- #update(last_seen, category_ids) ⇒ Object
Constructor Details
#initialize ⇒ Entry
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
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
6 7 8 |
# File 'lib/nfcollector/categoriser.rb', line 6 def categories @categories end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
5 6 7 |
# File 'lib/nfcollector/categoriser.rb', line 5 def hits @hits end |
#last_seen ⇒ Object (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 |