Class: NpbApi::Stats::Fielding
- Inherits:
-
Base
- Object
- Base
- NpbApi::Stats::Fielding
show all
- Defined in:
- lib/npb-api/stats/fielding.rb
Constant Summary
Constants inherited
from Base
Base::LEAGUES, Base::TEAMS, Base::TEAM_LEAGUES
Instance Attribute Summary collapse
Attributes inherited from Base
#league, #team, #year
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
all
Constructor Details
#initialize(row, team, league, year, position) ⇒ Fielding
Returns a new instance of Fielding.
30
31
32
33
34
35
36
|
# File 'lib/npb-api/stats/fielding.rb', line 30
def initialize(row, team, league, year, position)
@row = row
@team = team
@league = league
@year = year
@position = position
end
|
Instance Attribute Details
#position ⇒ Object
Returns the value of attribute position.
28
29
30
|
# File 'lib/npb-api/stats/fielding.rb', line 28
def position
@position
end
|
Class Method Details
.list(team, league, year) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/npb-api/stats/fielding.rb', line 4
def self.list(team, league, year)
raise UnknownTeamError unless TEAMS.include?(team)
raise UnknownLeagueError unless LEAGUES.include?(league)
position = ''
source(team, league, year).css('#stdivmaintbl tr').each_with_object([]) do |row, arr|
position = new_position(row) unless row.css('th.sthdfplayer').empty?
arr << new(row, team, league, year, position) if ststats?(row)
end
end
|
.url_key ⇒ Object
22
23
24
|
# File 'lib/npb-api/stats/fielding.rb', line 22
def self.url_key
'f'
end
|
Instance Method Details
#assists ⇒ Object
50
51
52
|
# File 'lib/npb-api/stats/fielding.rb', line 50
def assists
@row.children[9].children.text.to_i
end
|
#double_plays ⇒ Object
58
59
60
|
# File 'lib/npb-api/stats/fielding.rb', line 58
def double_plays
@row.children[13].children.text.to_i
end
|
#errors ⇒ Object
54
55
56
|
# File 'lib/npb-api/stats/fielding.rb', line 54
def errors
@row.children[11].children.text.to_i
end
|
#fielding_average ⇒ Object
67
68
69
|
# File 'lib/npb-api/stats/fielding.rb', line 67
def fielding_average
@row.children[17].children.text.to_f
end
|
#games ⇒ Object
42
43
44
|
# File 'lib/npb-api/stats/fielding.rb', line 42
def games
@row.children[5].children.text.to_i
end
|
#passed_ball ⇒ Object
62
63
64
65
|
# File 'lib/npb-api/stats/fielding.rb', line 62
def passed_ball
value = @row.children[15].children.text
value == '' ? nil : value.to_i
end
|
#player ⇒ Object
38
39
40
|
# File 'lib/npb-api/stats/fielding.rb', line 38
def player
@row.children[3].children.text
end
|
#put_outs ⇒ Object
46
47
48
|
# File 'lib/npb-api/stats/fielding.rb', line 46
def put_outs
@row.children[7].children.text.to_i
end
|