Class: Madden20MarketPrices::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/madden_20_market_prices/player.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, info = nil, cost = nil, price_change_percent = nil, ovr = nil) ⇒ Player

Returns a new instance of Player.



7
8
9
10
11
12
13
14
# File 'lib/madden_20_market_prices/player.rb', line 7

def initialize(name = nil, info = nil, cost = nil, price_change_percent = nil, ovr = nil)
    @name = name
    @info = info
    @cost = cost
    @price_change_percent = price_change_percent
    @ovr = ovr
    @@all << self
end

Instance Attribute Details

#costObject

Returns the value of attribute cost.



3
4
5
# File 'lib/madden_20_market_prices/player.rb', line 3

def cost
  @cost
end

#infoObject

Returns the value of attribute info.



3
4
5
# File 'lib/madden_20_market_prices/player.rb', line 3

def info
  @info
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/madden_20_market_prices/player.rb', line 3

def name
  @name
end

#ovrObject

Returns the value of attribute ovr.



3
4
5
# File 'lib/madden_20_market_prices/player.rb', line 3

def ovr
  @ovr
end

#price_change_percentObject

Returns the value of attribute price_change_percent.



3
4
5
# File 'lib/madden_20_market_prices/player.rb', line 3

def price_change_percent
  @price_change_percent
end

Class Method Details

.allObject



26
27
28
# File 'lib/madden_20_market_prices/player.rb', line 26

def self.all
    @@all
end

.find(index) ⇒ Object



30
31
32
# File 'lib/madden_20_market_prices/player.rb', line 30

def self.find(index)
    self.all[index - 1]
end

.new_from_prices_page(player) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/madden_20_market_prices/player.rb', line 16

def self.new_from_prices_page(player)
    self.new(
        player.css("div.list-info-player__player-name").text.strip,
        player.css("div.list-info-player__player-info").text.strip,
        player.css("div.cost-summary__price").text.strip,
        player.css("div.cost-summary__effect").text.strip,
        player.css("span.list-info-player__ovr-value").text.strip
    )
end

.reset!Object



34
35
36
# File 'lib/madden_20_market_prices/player.rb', line 34

def self.reset!
    self.all.clear
end