class Fatboy::ViewedItem

The viewed item class provides a (very) simple interface for interacting with views on Models. Almost always obtained from a TimeBasedPopularity, this struct simply shows the id of the model, the number of views, and the rank. NOTE: The highest-ranked item has rank 0. Ranks are 0-indexed.

Attributes

id[R]

Id of the model contained this this ViewedItem

rank[R]

The rank, 0 being the most viewed, of this item. The time period was pre-set on construction, typically from a Fatboy::TimeBasedView

views[R]

Amount this ViewedItem has been viewed in a time period. This time period was pre-set on construction.

Public Class Methods

new(id, views, rank) click to toggle source
# File lib/fatboy/viewed_item.rb, line 9
def initialize(id, views, rank)
  @id = id.to_i
  @views = views.to_i
  @rank = rank.to_i
end