Class: NpbApi::Stats::Team
- Inherits:
-
Object
- Object
- NpbApi::Stats::Team
- Defined in:
- lib/npb-api/stats/team.rb
Instance Attribute Summary collapse
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
Instance Method Summary collapse
- #draws ⇒ Object
- #games ⇒ Object
- #games_behind ⇒ Object
-
#initialize(row, league, year) ⇒ Team
constructor
A new instance of Team.
- #league ⇒ Object
- #loses ⇒ Object
- #team ⇒ Object
- #winning_percentage ⇒ Object
- #wins ⇒ Object
Constructor Details
#initialize(row, league, year) ⇒ Team
Returns a new instance of Team.
28 29 30 31 32 |
# File 'lib/npb-api/stats/team.rb', line 28 def initialize(row, league, year) @row = row @league = league @year = year end |
Instance Attribute Details
#year ⇒ Object (readonly)
Returns the value of attribute year.
26 27 28 |
# File 'lib/npb-api/stats/team.rb', line 26 def year @year end |
Class Method Details
.list(league, year) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/npb-api/stats/team.rb', line 8 def self.list(league, year) regular_reague = source(league, year).css('table.stdtblSubmain')[0] regular_reague.css('tr[align="center"]').each_with_object([]) do |row, arr| next if row.css('td.stdTeam').empty? # 行にチーム名が含まれていなかったらスキップ arr << new(row, league, year) end end |
Instance Method Details
#draws ⇒ Object
59 60 61 |
# File 'lib/npb-api/stats/team.rb', line 59 def draws @row.css('td.stdscore')[3].text.to_i end |
#games ⇒ Object
47 48 49 |
# File 'lib/npb-api/stats/team.rb', line 47 def games @row.css('td.stdscore')[0].text.to_i end |
#games_behind ⇒ Object
67 68 69 |
# File 'lib/npb-api/stats/team.rb', line 67 def games_behind @row.css('td.stdscore')[5].text end |
#league ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/npb-api/stats/team.rb', line 34 def league case @league when 'c' then 'central' when 'p' then 'pacific' when 'e' then 'eastern' when 'w' then 'western' end end |
#loses ⇒ Object
55 56 57 |
# File 'lib/npb-api/stats/team.rb', line 55 def loses @row.css('td.stdscore')[2].text.to_i end |
#team ⇒ Object
43 44 45 |
# File 'lib/npb-api/stats/team.rb', line 43 def team @row.css('td.stdTeam').text.gsub(/ /, '') end |
#winning_percentage ⇒ Object
63 64 65 |
# File 'lib/npb-api/stats/team.rb', line 63 def winning_percentage @row.css('td.stdscore')[4].text.to_f end |
#wins ⇒ Object
51 52 53 |
# File 'lib/npb-api/stats/team.rb', line 51 def wins @row.css('td.stdscore')[1].text.to_i end |