Class: Partyhat::ActivityComparison

Inherits:
Object
  • Object
show all
Defined in:
lib/partyhat/activity_comparison.rb

Instance Method Summary collapse

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

#rankObject



25
26
27
# File 'lib/partyhat/activity_comparison.rb', line 25

def rank
  @rank
end

#scoreObject



21
22
23
# File 'lib/partyhat/activity_comparison.rb', line 21

def score
  @score
end