Class: NpbApi::Pitching
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from NpbApi::Base
Instance Method Details
#table ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/npb_api/pitching.rb', line 5 def table extracted_table.map do |values| values.unshift(@year, @team, @league) hash = Hash[*[keys, values].transpose.flatten] hash = hash.map do |key, value| case key when :year, :team, :league, :player [key, value] when :throw [key, _throw(value)] when :winning_percentage [key, value.to_f] when :innings_pitched [key, innings_pitched(value, hash[:innings_pitched_2])] when :earned_run_average [key, earned_run_average(value)] else [key, value.to_i] end end.to_h hash.delete(:innings_pitched_2) # 投球回が2列で表現していたため、一箇所にまとめて小数点の部分を削除 hash.merge!(hold: 'NULL', hold_points: 'NULL') if farm? hash end end |