Class: QiitaScouter::Calculator
- Inherits:
-
Object
- Object
- QiitaScouter::Calculator
- Defined in:
- lib/qiita_scouter_calculator.rb
Overview
QiitaScouter Core
Instance Method Summary collapse
-
#calc_intelligence ⇒ Object
知力を計算 記事数 × 5 × (ストック数/10).
-
#calc_power_level ⇒ Object
戦闘力を計算 攻撃力、 知力、 すばやさの合計.
-
#calc_quickness ⇒ Object
すばやさを計算 Tag数 × (ストック数/10).
-
#calc_strength ⇒ Object
攻撃力を計算 フォロワー数 × 10 × (ストック数/10).
-
#initialize(user, articles) ⇒ Calculator
constructor
A new instance of Calculator.
Constructor Details
#initialize(user, articles) ⇒ Calculator
Returns a new instance of Calculator.
9 10 11 12 13 14 15 16 |
# File 'lib/qiita_scouter_calculator.rb', line 9 def initialize(user, articles) @url_name = user.url_name @followers = user.followers @items = user.items @tags = articles.reduce([]) { |a, e|a += e.; a }.uniq.size stock_count = articles.map(&:stock_count).reduce(&:+) @stock_rate = stock_count / 10 end |
Instance Method Details
#calc_intelligence ⇒ Object
知力を計算記事数 × 5 × (ストック数/10)
26 27 28 |
# File 'lib/qiita_scouter_calculator.rb', line 26 def calc_intelligence @items * 5 * @stock_rate end |
#calc_power_level ⇒ Object
戦闘力を計算攻撃力、 知力、 すばやさの合計
38 39 40 |
# File 'lib/qiita_scouter_calculator.rb', line 38 def calc_power_level [calc_strength, calc_intelligence, calc_quickness].reduce(&:+) end |
#calc_quickness ⇒ Object
すばやさを計算Tag数 × (ストック数/10)
32 33 34 |
# File 'lib/qiita_scouter_calculator.rb', line 32 def calc_quickness @tags * @stock_rate end |
#calc_strength ⇒ Object
攻撃力を計算フォロワー数 × 10 × (ストック数/10)
20 21 22 |
# File 'lib/qiita_scouter_calculator.rb', line 20 def calc_strength @followers * 10 * @stock_rate end |