Class: InOrOut::PlayerExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/in_or_out/models/player_extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(match_data) ⇒ PlayerExtractor

Returns a new instance of PlayerExtractor.



4
5
6
# File 'lib/in_or_out/models/player_extractor.rb', line 4

def initialize(match_data)
  @data = match_data
end

Instance Method Details

#extractObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/in_or_out/models/player_extractor.rb', line 8

def extract
  if ready?
    @data.css('.player').map do |player|
      build_player(
          extract_name(player),
          extract_team(player),
          extract_position(player),
          extract_number(player)
      )
    end
  else
    []
  end
end