Class: FantasyFootball::Player

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePlayer

Returns a new instance of Player.



7
8
9
# File 'lib/fantasy_football/player.rb', line 7

def initialize
  save
end

Instance Attribute Details

#ageObject

Returns the value of attribute age.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def age
  @age
end

#collegeObject

Returns the value of attribute college.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def college
  @college
end

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def height
  @height
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def name
  @name
end

#positionObject

Returns the value of attribute position.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def position
  @position
end

#projectionObject

Returns the value of attribute projection.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def projection
  @projection
end

#rankObject

Returns the value of attribute rank.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def rank
  @rank
end

#teamObject

Returns the value of attribute team.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def team
  @team
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def url
  @url
end

#weekObject

Returns the value of attribute week.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def week
  @week
end

#weightObject

Returns the value of attribute weight.



3
4
5
# File 'lib/fantasy_football/player.rb', line 3

def weight
  @weight
end

Class Method Details

.allObject

Class variable reader



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

def self.all # Class variable reader
  @@all
end

.find_by_position(position) ⇒ Object



19
20
21
# File 'lib/fantasy_football/player.rb', line 19

def self.find_by_position(position)
  all.select {|i| i.position == position.upcase}.sort {|a,b| a.rank.to_i <=> b.rank.to_i}
end

.find_by_rank_and_position(rank, position) ⇒ Object



23
24
25
# File 'lib/fantasy_football/player.rb', line 23

def self.find_by_rank_and_position(rank, position)
  all.find {|i| i.rank == rank && i.position == position.upcase}
end

Instance Method Details

#saveObject



15
16
17
# File 'lib/fantasy_football/player.rb', line 15

def save
  @@all << self
end