Class: Basketball::Entity
- Inherits:
-
Object
- Object
- Basketball::Entity
show all
- Includes:
- Comparable
- Defined in:
- lib/basketball/entity.rb
Overview
Base class for uniquely identifiable classes. Subclasses are simply based on a string-based ID and comparison/sorting/equality will be done in a case-insensitive manner.
Direct Known Subclasses
Common::Player, Draft::Event, Draft::FrontOffice, Draft::Room, Season::Calendar, Season::Conference, Season::Coordinator, Season::Division, Season::League, Season::Opponent, Season::Record, Season::Standings, Season::Team
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(id = nil) ⇒ Entity
Returns a new instance of Entity.
11
12
13
|
# File 'lib/basketball/entity.rb', line 11
def initialize(id = nil)
@id = id
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
9
10
11
|
# File 'lib/basketball/entity.rb', line 9
def id
@id
end
|
Instance Method Details
#<=>(other) ⇒ Object
15
16
17
|
# File 'lib/basketball/entity.rb', line 15
def <=>(other)
comparable_id <=> other.comparable_id
end
|
#==(other) ⇒ Object
Also known as:
eql?
19
20
21
|
# File 'lib/basketball/entity.rb', line 19
def ==(other)
comparable_id == other.comparable_id
end
|
#comparable_id ⇒ Object
32
33
34
|
# File 'lib/basketball/entity.rb', line 32
def comparable_id
id.to_s.upcase
end
|
#hash ⇒ Object
24
25
26
|
# File 'lib/basketball/entity.rb', line 24
def hash
comparable_id.hash
end
|
#to_s ⇒ Object
28
29
30
|
# File 'lib/basketball/entity.rb', line 28
def to_s
id.to_s
end
|