Class: Improves::RatingBoost

Inherits:
ImproveHunter show all
Defined in:
app/services/improves/rating_boost.rb

Overview

Used to apply an Improvements::RatingBoost to a hunter if the hunter is a valid target

Instance Method Summary collapse

Methods inherited from ImproveHunter

#check, for, #hunter_not_advanced?, #hunter_playbook_mismatch?

Constructor Details

#initialize(hunters_improvement) ⇒ RatingBoost

Returns a new instance of RatingBoost.


7
8
9
10
# File 'app/services/improves/rating_boost.rb', line 7

def initialize(hunters_improvement)
  super
  @rating = @improvement.configured_rating(@hunters_improvement)
end

Instance Method Details

#improveObject


12
13
14
15
16
# File 'app/services/improves/rating_boost.rb', line 12

def improve
  return false unless valid?
  rating = { @rating => @hunter.send(@rating) + 1 }
  @hunter.update(rating)
end

#over_max_limit?Boolean

Returns:

  • (Boolean)

25
26
27
# File 'app/services/improves/rating_boost.rb', line 25

def over_max_limit?
  @hunter.send(@rating) >= @improvement.stat_limit
end

#valid?Boolean

Returns:

  • (Boolean)

18
19
20
21
22
23
# File 'app/services/improves/rating_boost.rb', line 18

def valid?
  super
  check :over_max_limit?, :hunter,
        "#{@rating} rating would exceed max for improvement."
  @hunters_improvement.errors.none?
end