mlb_gd2 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed654900774c0d872251c4851a6f038a70b6434d
4
- data.tar.gz: 42c51f436fca0f6fda8d8fd69903ffceaace7760
3
+ metadata.gz: bb21926f67ce7719774714073bfc9b26182cc5b1
4
+ data.tar.gz: 442691c4277b7ebe62e48a59869ca6bf62a1be86
5
5
  SHA512:
6
- metadata.gz: 553f5e6b237f215d381d6286469e36f89323a857f4b8712cf6036f7d52e47672325cc35dc182177cc2b6433e813f7568400030b5b40e80e3fcebd2347d22658f
7
- data.tar.gz: 0a1c422cffd2d29491fba7ef4658abda2ecc281dcfd76343d91b0455d2524b3c06d4f51bdc574a28d0227a91ed6ef467b8a26a9a037ff76363c734b9e83ce247
6
+ metadata.gz: 0101a03ffdef3c3253c928131753bc3cff6ba0ae39162402b86d398c3d401a1ddccb63261c863a611ea31e5ddad9e9354c65bd74de88b5a6bffb26ccf5d64e61
7
+ data.tar.gz: 3f4922c6abdef46b9a80571652eb36a9b31aa4ac822c89963023e43c9419a81ccfde2fd161ea16dc69448c23586ffeacead3f877707ea505cc029c16d8699168
@@ -0,0 +1,16 @@
1
+ require "net/http"
2
+ require "nokogiri"
3
+ require_relative "./helpers"
4
+
5
+ class Batter
6
+
7
+ attr_reader :name, :position
8
+
9
+ include Helpers
10
+
11
+ def initialize(batter_xml)
12
+ @name = batter_xml.attribute("name_display_first_last").value
13
+ @position = batter_xml.attribute("pos").value
14
+ end
15
+
16
+ end
@@ -0,0 +1,15 @@
1
+ require "net/http"
2
+ require "nokogiri"
3
+ require_relative "./helpers"
4
+
5
+ class Pitcher
6
+
7
+ attr_reader :name, :position
8
+
9
+ include Helpers
10
+
11
+ def initialize(pitcher_xml)
12
+ @name = pitcher_xml.attribute("name_display_first_last").value
13
+ end
14
+
15
+ end
data/lib/mlb_gd2/team.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require "net/http"
2
2
  require "nokogiri"
3
3
  require_relative "./helpers"
4
+ require_relative "./batter"
5
+ require_relative "./pitcher"
4
6
 
5
7
  class Team
6
8
 
7
- attr_reader :name, :linescore, :runs, :hits, :errors
9
+ attr_reader :name, :linescore, :runs, :hits, :errors, :batters, :pitchers
8
10
 
9
11
  include Helpers
10
12
 
@@ -14,6 +16,8 @@ class Team
14
16
  @runs = boxscore.xpath("//linescore").first.attribute("#{flag}_team_runs").value
15
17
  @hits = boxscore.xpath("//linescore").first.attribute("#{flag}_team_hits").value
16
18
  @errors = boxscore.xpath("//linescore").first.attribute("#{flag}_team_errors").value
19
+ @batters = boxscore.search("batting[team_flag='#{flag}']>batter").map { |batter_xml| Batter.new(batter_xml) }
20
+ @pitchers = boxscore.search("pitching[team_flag='#{flag}']>pitcher").map { |pitcher_xml| Pitcher.new(pitcher_xml) }
17
21
  end
18
22
 
19
23
  end
data/lib/mlb_gd2.rb CHANGED
@@ -1,2 +1,5 @@
1
1
  require 'mlb_gd2/game'
2
- require 'mlb_gd2/gameday'
2
+ require 'mlb_gd2/gameday'
3
+ require 'mlb_gd2/team'
4
+ require 'mlb_gd2/batter'
5
+ require 'mlb_gd2/pitcher'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mlb_gd2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Firth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -31,9 +31,11 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/mlb_gd2.rb
34
+ - lib/mlb_gd2/batter.rb
34
35
  - lib/mlb_gd2/game.rb
35
36
  - lib/mlb_gd2/gameday.rb
36
37
  - lib/mlb_gd2/helpers.rb
38
+ - lib/mlb_gd2/pitcher.rb
37
39
  - lib/mlb_gd2/team.rb
38
40
  homepage: http://rubygems.org/gems/mlb_gd2
39
41
  licenses: