Class: Stattleship::Models::Player

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/stattleship/models/player.rb

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/stattleship/models/player.rb', line 4

def active?
  active
end

#dumpObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/stattleship/models/player.rb', line 58

def dump
  {
    active: active?,
    birth_date: birth_date,
    first_name: first_name,
    handedness: handedness,
    height: height,
    humanized_salary: humanized_salary,
    inflielder: inflielder?,
    label: label,
    last_name: last_name,
    name: name,
    outflielder: outflielder?,
    pitcher: pitcher?,
    position_abbreviation: position_abbreviation,
    position_name: position_name,
    salary: salary,
    salary_currency: salary_currency,
    school: school,
    slug: slug,
    sport: sport,
    team_name: team_name,
    team_nickname: team_nickname,
    team: team_hash,
    unit_of_height: unit_of_height,
    unit_of_weight: unit_of_weight,
    weight: weight,
    years_of_experience: years_of_experience,
    city: city,
    state: state,
    country: country,
    draft_season: draft_season,
    draft_round: draft_round,
    draft_overall_pick: draft_overall_pick,
    draft_team_name: draft_team_name,
  }
end

#full_nameObject



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

def full_name
  if name == ''
    "#{first_name} #{last_name}"
  else
    name
  end
end

#inflielder?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
49
# File 'lib/stattleship/models/player.rb', line 43

def inflielder?
  position_abbreviation == '1B' ||
  position_abbreviation == '2B' ||
  position_abbreviation == '3B' ||
  position_abbreviation == 'SS' ||
  position_abbreviation == 'C'
end

#labelObject



16
17
18
# File 'lib/stattleship/models/player.rb', line 16

def label
  "#{full_name} (#{position_abbreviation}) - #{team_nickname}"
end

#outflielder?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
# File 'lib/stattleship/models/player.rb', line 51

def outflielder?
  position_abbreviation == 'LF' ||
  position_abbreviation == 'CF' ||
  position_abbreviation == 'RF' ||
  position_abbreviation == 'OF'
end

#pitcher?Boolean

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/stattleship/models/player.rb', line 38

def pitcher?
  position_abbreviation == 'SP' ||
  position_abbreviation == 'RP'
end

#team_hashObject



32
33
34
35
36
# File 'lib/stattleship/models/player.rb', line 32

def team_hash
  if team
    team.dump
  end
end

#team_nameObject



20
21
22
23
24
# File 'lib/stattleship/models/player.rb', line 20

def team_name
  if team
    team.name
  end
end

#team_nicknameObject



26
27
28
29
30
# File 'lib/stattleship/models/player.rb', line 26

def team_nickname
  if team
    team.nickname
  end
end