Class: NbaInfo::Team
- Inherits:
-
Object
- Object
- NbaInfo::Team
- Defined in:
- lib/nba_info/team.rb
Constant Summary collapse
- @@nba =
{:east => [], :west => []}
Instance Attribute Summary collapse
-
#diff ⇒ Object
Returns the value of attribute diff.
-
#gb ⇒ Object
Returns the value of attribute gb.
-
#l_ten ⇒ Object
Returns the value of attribute l_ten.
-
#name ⇒ Object
Returns the value of attribute name.
-
#opp_ppg ⇒ Object
Returns the value of attribute opp_ppg.
-
#place ⇒ Object
Returns the value of attribute place.
-
#ppg ⇒ Object
Returns the value of attribute ppg.
-
#record ⇒ Object
Returns the value of attribute record.
-
#streak ⇒ Object
Returns the value of attribute streak.
-
#win_pct ⇒ Object
Returns the value of attribute win_pct.
Class Method Summary collapse
Instance Method Summary collapse
-
#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 |
# File 'lib/nba_info/team.rb', line 7 def initialize(team_hash) team_hash.each do |key, val| self.send "#{key}=", val end end |
Instance Attribute Details
#diff ⇒ Object
Returns the value of attribute diff.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def diff @diff end |
#gb ⇒ Object
Returns the value of attribute gb.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def gb @gb end |
#l_ten ⇒ Object
Returns the value of attribute l_ten.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def l_ten @l_ten end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def name @name end |
#opp_ppg ⇒ Object
Returns the value of attribute opp_ppg.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def opp_ppg @opp_ppg end |
#place ⇒ Object
Returns the value of attribute place.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def place @place end |
#ppg ⇒ Object
Returns the value of attribute ppg.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def ppg @ppg end |
#record ⇒ Object
Returns the value of attribute record.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def record @record end |
#streak ⇒ Object
Returns the value of attribute streak.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def streak @streak end |
#win_pct ⇒ Object
Returns the value of attribute win_pct.
3 4 5 |
# File 'lib/nba_info/team.rb', line 3 def win_pct @win_pct end |
Class Method Details
.add_stats ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/nba_info/team.rb', line 28 def self.add_stats self.create stats = NbaInfo::Scraper.scrape_stats @@nba[:east].each_with_index do |team, i| stats[:east][i].each do |key, val| team.send "#{key}=", val end end @@nba[:west].each_with_index do |team, i| stats[:west][i].each do |key, val| team.send "#{key}=", val end end @@nba end |
.create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nba_info/team.rb', line 13 def self.create nba = NbaInfo::Scraper.scrape_team if @@nba[:east].empty? || @@nba[:west].empty? nba[:east].each do |team| t = self.new(team) @@nba[:east] << t end nba[:west].each do |team| t = self.new(team) @@nba[:west] << t end end @@nba end |