Class: Stattleship::Models::LineUp

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

Instance Method Summary collapse

Instance Method Details

#dumpObject


55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/stattleship/models/line_up.rb', line 55

def dump
  {
    id: id,
    player_name: player_name,
    inning_half: inning_half,
    position_name: position_name,
    position_abbreviation: position_abbreviation,
    inning: inning,
    batting_order: batting_order,
    lineup_position: lineup_position,
    sequence: sequence,
  }
end

#inflielder?Boolean

Returns:

  • (Boolean)

39
40
41
42
43
44
45
# File 'lib/stattleship/models/line_up.rb', line 39

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

#outflielder?Boolean

Returns:

  • (Boolean)

47
48
49
50
51
52
# File 'lib/stattleship/models/line_up.rb', line 47

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

#pitcher?Boolean

Returns:

  • (Boolean)

34
35
36
37
# File 'lib/stattleship/models/line_up.rb', line 34

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

#player_labelObject


12
13
14
# File 'lib/stattleship/models/line_up.rb', line 12

def player_label
  player.label
end

#player_nameObject


8
9
10
# File 'lib/stattleship/models/line_up.rb', line 8

def player_name
  player.full_name
end

#team_hashObject


28
29
30
31
32
# File 'lib/stattleship/models/line_up.rb', line 28

def team_hash
  if team
    team.dump
  end
end

#team_nameObject


16
17
18
19
20
# File 'lib/stattleship/models/line_up.rb', line 16

def team_name
  if team
    team.name
  end
end

#team_nicknameObject


22
23
24
25
26
# File 'lib/stattleship/models/line_up.rb', line 22

def team_nickname
  if team
    team.nickname
  end
end

#to_sentenceObject


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

def to_sentence
  "#{player_label} : #{inning_half} #{inning} inning #{batting_order} batting order #{lineup_position} lineup position"
end