Class: SimulatorTeam

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/simulator_team.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dump!Object



19
20
21
22
23
24
25
26
27
# File 'app/models/simulator_team.rb', line 19

def self.dump!
  SimulatorChampionship.all.each do |championship|
    FootStats::Team.all(championship: championship.source_id).each do |foot_stats_team|
      team = self.find_or_create_by_source_id foot_stats_team.source_id
      team.update_attributes foot_stats_team.attributes
      SimulatorChampionshipParticipation.find_or_create_by_simulator_team_id_and_simulator_championship_id team.id, championship.id
    end
  end
end

.to_foot_statsObject



15
16
17
# File 'app/models/simulator_team.rb', line 15

def self.to_foot_stats
  { 'Equipe' => all.map(&:to_foot_stats) }
end

Instance Method Details

#to_foot_statsObject



6
7
8
9
10
11
12
13
# File 'app/models/simulator_team.rb', line 6

def to_foot_stats
  {
    '@Id'     => self.source_id,
    '@Nome'   => self.full_name,
    '@Cidade' => self.city,
    '@Pais'   => self.country
  }
end