Class: Partyhat::SkillComparison

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

Instance Method Summary collapse

Constructor Details

#initialize(first_skill, second_skill) ⇒ SkillComparison

Returns a new instance of SkillComparison.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/partyhat/skill_comparison.rb', line 9

def initialize first_skill, second_skill
  # Check the classes so they don't fail
  unless (first_skill.class == Partyhat::Skill) && (second_skill.class == Partyhat::Skill)
    raise InvalidArgumentError 'You can only compare two Skill objects.'
  end
  # Assign instance variables
  @first_skill  = first_skill
  @second_skill = second_skill
  # Perform comparison
  @level        = @second_skill.level - @first_skill.level
  @experience   = @second_skill.experience - @first_skill.experience
  @rank         = @second_skill.rank - @first_skill.rank
end

Instance Method Details

#experienceObject



27
28
29
# File 'lib/partyhat/skill_comparison.rb', line 27

def experience
  @experience
end

#levelObject



23
24
25
# File 'lib/partyhat/skill_comparison.rb', line 23

def level
  @level
end

#rankObject



31
32
33
# File 'lib/partyhat/skill_comparison.rb', line 31

def rank
  @rank
end