espn_nba_fantasy 0.0.4.2 → 0.0.5

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
  SHA256:
3
- metadata.gz: 83a5c2da0e0d31e6b001446932c7a662106beab66939bb104579ee750f57c7ae
4
- data.tar.gz: ea0cf431f9f38b8b9d828773a408a95613200d7300ba2debc85270555b0a87fa
3
+ metadata.gz: 16fb774021db8dfb88cbb618a2eba2a1ea8b72bd9b233e013557a36cfbb07b8f
4
+ data.tar.gz: 418d47edb6aa4569dc52e1b96dfcfb87fd0e3d9a0990465d455766b785dc171b
5
5
  SHA512:
6
- metadata.gz: 52999c9d94429c9d185df2954830a67a7de9d23ddf1058569a7e3624bc79900a69faa99cc5d24de48bb4aee2a505a7cb7abe19fb2eb625e0af751e107c2f6a00
7
- data.tar.gz: 9119715738ed4670859edb933f82e588da837177cfa529f1768797a8b0b7dba7c0514a9f4e803eed98de3cb1a7ad18fce01d0137dc06240c8df8fe1ea62c675e
6
+ metadata.gz: 0a9cd198d656352685ba648193a3d1d7286ace3842cba6a65beac6c504281546722257e92a6f70f8814c4d10a4cf1578884109f7bb8d58a8732f84157e222309
7
+ data.tar.gz: d32621f9f42263337d3ce84db10a1399b035680c185a2f968525d7a30b949fa4379c3823456a42cd686845f18bc0ff8832f486c5eb84fe1a61c5d44b21a8cc39
@@ -9,18 +9,20 @@ module ESPNNBAFantasy
9
9
 
10
10
  include PlayerFinder
11
11
 
12
- attr_accessor :teams, :stat_data
12
+ attr_accessor :teams, :stat_data, :league_id, :name, :current_start_year, :current_end_year
13
13
 
14
14
  #initializes the league
15
15
 
16
16
  def initialize(league_id, year, s2, sw)
17
- @league_id = league_id
18
-
19
17
  @uri = "https://lm-api-reads.fantasy.espn.com/apis/v3/games/fba/seasons/#{year}/segments/0/leagues/#{league_id}?view=mRoster&view=mSettings&view=mTeam&view=modular&view=mNav"
20
18
  @cookies = {'espn_s2': "#{s2}", 'SWID': "#{sw}"}
21
19
  @data = JSON.parse(RestClient.get(@uri, {cookies: @cookies}))
22
20
  @teams = make_team_objects
23
21
  @stat_data = make_stat_data
22
+ @league_id = @data['id']
23
+ @name = @data['name']
24
+ @current_start_year = @data['seasonId']
25
+ @current_end_year = @current_start_year + 1
24
26
  end
25
27
 
26
28
  def to_s
@@ -36,7 +38,7 @@ module ESPNNBAFantasy
36
38
  #pull up a Player object based on their name and their team
37
39
 
38
40
  def findplayer(team_name, str)
39
- team = teams.select{|t| t.name == team_name}.first
41
+ team = @teams.select{|t| t.name == team_name}.first
40
42
  return "No team named #{team_name}" unless team
41
43
 
42
44
  find_players(team.players, str) || "#{str} cannot be found in #{team_name}'s roster"
@@ -6,16 +6,21 @@ module ESPNNBAFantasy
6
6
 
7
7
  include CalculateStats
8
8
 
9
- attr_reader :name, :player_id, :position, :stats, :team
9
+ attr_reader :first_name, :last_name, :full_name,
10
+ :player_id, :position, :stats, :team,
11
+ :slug
10
12
 
11
13
  #basic initialization with attributes
12
14
 
13
15
  def initialize(player, team)
14
- @name = player['fullName']
16
+ @first_name = player['firstName']
17
+ @last_name = player['lastName']
18
+ @full_name = player['fullName']
15
19
  @player_id = player['id']
16
20
  @position = ESPNNBAFantasy::POSITION_MAP[player['defaultPositionId']-1]
17
21
  @stats = stat_card_maker(player)
18
22
  @team = team
23
+ @slug = @full_name.scan(/\w+|\s/).join.downcase.split(' ').join('-')
19
24
  end
20
25
 
21
26
  def to_s
@@ -3,7 +3,7 @@
3
3
  module PlayerFinder
4
4
 
5
5
  def find_players(arr, matcher)
6
- arr.select{|p| p.name.downcase == matcher.downcase}.first
6
+ arr.select{|p| p.full_name.downcase == matcher.downcase}.first
7
7
  end
8
8
 
9
9
  end
@@ -38,15 +38,15 @@ module ESPNNBAFantasy
38
38
  own_players = to_trade.map{|player| find_players(players, player)}
39
39
  other_players = to_receive.map{|player| find_players(other_team.players, player)}
40
40
  return "This trade included players not one of the specified teams" if (own_players.include?(nil)|| other_players.include?(nil))
41
- {'Trading:' => own_players.map{|p| p.name},
42
- 'Receiving:' => other_players.map{|p| p.name}}.merge(new_team_stats(own_players, other_players))
41
+ {'Trading:' => own_players.map{|p| p.full_name},
42
+ 'Receiving:' => other_players.map{|p| p.full_name}}.merge(new_team_stats(own_players, other_players))
43
43
 
44
44
  end
45
45
 
46
46
  private
47
47
 
48
48
  def roster_names
49
- players.map(&:name)
49
+ players.map(&:full_name)
50
50
  end
51
51
 
52
52
  def stat_differences(old, new)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: espn_nba_fantasy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Usborn Ocampo