Class: Partyhat::ActivityComparison
- Inherits:
-
Object
- Object
- Partyhat::ActivityComparison
- Defined in:
- lib/partyhat/activity_comparison.rb
Instance Method Summary collapse
-
#initialize(first_activity, second_activity) ⇒ ActivityComparison
constructor
A new instance of ActivityComparison.
- #rank ⇒ Object
- #score ⇒ Object
Constructor Details
#initialize(first_activity, second_activity) ⇒ ActivityComparison
Returns a new instance of ActivityComparison.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/partyhat/activity_comparison.rb', line 8 def initialize first_activity, second_activity # Check the classes so they don't fail unless (first_activity.class == Partyhat::Activity) && (second_activity.class == Partyhat::Activity) raise InvalidArgumentError 'You can only compare two Partyhat::Activity objects.' end # Assign instance variables @first_activity = first_activity @second_activity = second_activity # Perform comparison @score = @second_activity.score - @first_activity.score @rank = @second_activity.rank - @first_activity.rank end |
Instance Method Details
#rank ⇒ Object
25 26 27 |
# File 'lib/partyhat/activity_comparison.rb', line 25 def rank @rank end |
#score ⇒ Object
21 22 23 |
# File 'lib/partyhat/activity_comparison.rb', line 21 def score @score end |