Class: Player

Inherits:
Object
  • Object
show all
Defined in:
lib/redbull_team/player.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Player

Returns a new instance of Player.



4
5
6
7
# File 'lib/redbull_team/player.rb', line 4

def initialize(hash)
  hash.each{|key, value| self.send("#{key}=", value)}
  self.class.all << self
end

Instance Attribute Details

#ageObject

Returns the value of attribute age.



2
3
4
# File 'lib/redbull_team/player.rb', line 2

def age
  @age
end

#heightObject

Returns the value of attribute height.



2
3
4
# File 'lib/redbull_team/player.rb', line 2

def height
  @height
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/redbull_team/player.rb', line 2

def name
  @name
end

#positionObject

Returns the value of attribute position.



2
3
4
# File 'lib/redbull_team/player.rb', line 2

def position
  @position
end

#weightObject

Returns the value of attribute weight.



2
3
4
# File 'lib/redbull_team/player.rb', line 2

def weight
  @weight
end

Class Method Details

.allObject



8
9
10
# File 'lib/redbull_team/player.rb', line 8

def self.all
  @@all
end

.countObject



14
15
16
# File 'lib/redbull_team/player.rb', line 14

def self.count
  self.all.length
end

.resetObject



11
12
13
# File 'lib/redbull_team/player.rb', line 11

def self.reset
  self.all.clear
end