Class: Pairity::Person
- Inherits:
-
Object
- Object
- Pairity::Person
- Defined in:
- lib/pairity/person.rb
Constant Summary collapse
- @@id =
0
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#tier ⇒ Object
Returns the value of attribute tier.
Instance Method Summary collapse
- #<=>(other_person) ⇒ Object
-
#initialize(name:, tier: 2) ⇒ Person
constructor
A new instance of Person.
- #to_s ⇒ Object
Constructor Details
#initialize(name:, tier: 2) ⇒ Person
Returns a new instance of Person.
7 8 9 10 |
# File 'lib/pairity/person.rb', line 7 def initialize(name:, tier: 2) @name = name @tier = !((1..3) === tier) ? 2 : tier end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/pairity/person.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/pairity/person.rb', line 5 def name @name end |
#tier ⇒ Object
Returns the value of attribute tier.
5 6 7 |
# File 'lib/pairity/person.rb', line 5 def tier @tier end |
Instance Method Details
#<=>(other_person) ⇒ Object
12 13 14 15 16 |
# File 'lib/pairity/person.rb', line 12 def <=>(other_person) return 1 if name == "Han Solo" return -1 if other_person.name == "Han Solo" name <=> other_person.name end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/pairity/person.rb', line 18 def to_s "#{name}" end |