Class: FifaRankings::Team
- Inherits:
-
Object
- Object
- FifaRankings::Team
- Defined in:
- lib/fifa_rankings/team.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#captain ⇒ Object
Returns the value of attribute captain.
-
#confederation ⇒ Object
Returns the value of attribute confederation.
-
#head_coach ⇒ Object
Returns the value of attribute head_coach.
-
#most_caps ⇒ Object
Returns the value of attribute most_caps.
-
#movement ⇒ Object
Returns the value of attribute movement.
-
#name ⇒ Object
Returns the value of attribute name.
-
#points ⇒ Object
Returns the value of attribute points.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#top_scorer ⇒ Object
Returns the value of attribute top_scorer.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .all ⇒ Object
- .create_from_array(array) ⇒ Object
- .find_by_name(name) ⇒ Object
- .find_by_rank(rank) ⇒ Object
- .points_greater_than(number) ⇒ Object
- .sort_by_rank ⇒ Object
Instance Method Summary collapse
- #add_attributes(attributes_hash) ⇒ Object
-
#initialize(team_hash) ⇒ Team
constructor
A new instance of Team.
Constructor Details
#initialize(team_hash) ⇒ Team
Returns a new instance of Team.
7 8 9 10 11 12 |
# File 'lib/fifa_rankings/team.rb', line 7 def initialize(team_hash) team_hash.each do |k,v| self.send(("#{k}="),v) end @@all << self end |
Instance Attribute Details
#captain ⇒ Object
Returns the value of attribute captain.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def captain @captain end |
#confederation ⇒ Object
Returns the value of attribute confederation.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def confederation @confederation end |
#head_coach ⇒ Object
Returns the value of attribute head_coach.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def head_coach @head_coach end |
#most_caps ⇒ Object
Returns the value of attribute most_caps.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def most_caps @most_caps end |
#movement ⇒ Object
Returns the value of attribute movement.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def movement @movement end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def name @name end |
#points ⇒ Object
Returns the value of attribute points.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def points @points end |
#rank ⇒ Object
Returns the value of attribute rank.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def rank @rank end |
#top_scorer ⇒ Object
Returns the value of attribute top_scorer.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def top_scorer @top_scorer end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/fifa_rankings/team.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
35 36 37 |
# File 'lib/fifa_rankings/team.rb', line 35 def self.all @@all end |
.create_from_array(array) ⇒ Object
18 19 20 21 |
# File 'lib/fifa_rankings/team.rb', line 18 def self.create_from_array(array) # create Team instances from an array of hashes array.each {|team| self.new(team)} end |
.find_by_name(name) ⇒ Object
43 44 45 |
# File 'lib/fifa_rankings/team.rb', line 43 def self.find_by_name(name) self.all.detect {|team| team.name.downcase == name.downcase} end |
.find_by_rank(rank) ⇒ Object
39 40 41 |
# File 'lib/fifa_rankings/team.rb', line 39 def self.find_by_rank(rank) self.all.detect {|team| team.rank == rank} end |
.points_greater_than(number) ⇒ Object
14 15 16 |
# File 'lib/fifa_rankings/team.rb', line 14 def self.points_greater_than(number) self.all.select {|team| team.points > number} end |
.sort_by_rank ⇒ Object
31 32 33 |
# File 'lib/fifa_rankings/team.rb', line 31 def self.sort_by_rank self.all.sort_by {|team| team.rank} end |
Instance Method Details
#add_attributes(attributes_hash) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/fifa_rankings/team.rb', line 23 def add_attributes(attributes_hash) # add attributes to Team instances from a hash for the detail view attributes_hash.each do |k,v| self.send(("#{k}="),v) end self end |