Class: QiitaMail::Selector::ScoredItem

Inherits:
Object
  • Object
show all
Defined in:
lib/qiita_mail/selector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ ScoredItem

Returns a new instance of ScoredItem.



66
67
68
69
# File 'lib/qiita_mail/selector.rb', line 66

def initialize(item)
  @item  = item
  @score = item.stock_count * 10 + item.comment_count * 20
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



63
64
65
# File 'lib/qiita_mail/selector.rb', line 63

def item
  @item
end

#scoreObject (readonly)

Returns the value of attribute score.



64
65
66
# File 'lib/qiita_mail/selector.rb', line 64

def score
  @score
end

Instance Method Details

#<=>(rhs) ⇒ Object



75
76
77
# File 'lib/qiita_mail/selector.rb', line 75

def <=>(rhs)
  self.score <=> rhs.score
end

#add_score(v) ⇒ Object



71
72
73
# File 'lib/qiita_mail/selector.rb', line 71

def add_score(v)
  @score += v
end