Class: Infostrada::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/infostrada/commands.rb

Overview

The class containing the methods used by the command line tool.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.selected_editionObject

Returns the value of attribute selected_edition.



5
6
7
# File 'lib/infostrada/commands.rb', line 5

def selected_edition
  @selected_edition
end

Class Method Details

.editionsObject



13
14
15
16
17
18
# File 'lib/infostrada/commands.rb', line 13

def editions
  get_editions.each do |edition|
    print_id_col(edition.id)
    print "#{edition.competition_name} #{edition.season}\n".bold
  end
end

.select_edition(edition_id) ⇒ Object



20
21
22
23
# File 'lib/infostrada/commands.rb', line 20

def select_edition(edition_id)
  get_editions
  @selected_edition = @editions.find { |edition| edition.id == edition_id.to_i }
end

.selected_edition_stringObject



7
8
9
10
11
# File 'lib/infostrada/commands.rb', line 7

def selected_edition_string
  if @selected_edition
    "#{@selected_edition.competition_name} #{@selected_edition.season}"
  end
end

.show_player(person_id) ⇒ Object



42
43
44
45
46
47
# File 'lib/infostrada/commands.rb', line 42

def show_player(person_id)
  person = PersonInfo.where(person_id: person_id)
  nickname = person.nickname

  print_person(person, nickname)
end

.show_squad(team_id) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/infostrada/commands.rb', line 33

def show_squad(team_id)
  players = Squad.where(edition_id: @selected_edition.id, team_id: team_id)
  players.each do |player|
    print_id_col(player.person_id)
    print "#{player.function[0]} ".bold.red
    print "#{player.name}\n".bold
  end
end

.show_teamsObject



25
26
27
28
29
30
31
# File 'lib/infostrada/commands.rb', line 25

def show_teams
  edition_teams = @selected_edition.teams
  edition_teams.each do |team|
    print_id_col(team.id)
    print "#{team.name}\n".bold
  end
end