class Rubygoal::MatchData::Factory

Attributes

game[R]
side[R]

Public Class Methods

new(game, side) click to toggle source
# File lib/rubygoal/match_data.rb, line 8
def initialize(game, side)
  @game = game
  @side = side
end

Public Instance Methods

create() click to toggle source
# File lib/rubygoal/match_data.rb, line 13
def create
  MatchData.new(
    my_score,
    other_score,
    ball_match_position,
    my_positions,
    other_positions,
    time
  )
end

Private Instance Methods

away_players_positions() click to toggle source
# File lib/rubygoal/match_data.rb, line 38
def away_players_positions
  remove_goalkeeper_position(game.away_players_positions)
end
ball_field_position() click to toggle source
# File lib/rubygoal/match_data.rb, line 62
def ball_field_position
  Field.field_position(ball_position, side)
end
ball_match_position() click to toggle source
# File lib/rubygoal/match_data.rb, line 66
def ball_match_position
  Field.position_to_percentages(ball_field_position)
end
home_players_positions() click to toggle source
# File lib/rubygoal/match_data.rb, line 34
def home_players_positions
  remove_goalkeeper_position(game.home_players_positions)
end
my_positions() click to toggle source
# File lib/rubygoal/match_data.rb, line 54
def my_positions
  send("#{side}_players_positions")
end
my_score() click to toggle source
# File lib/rubygoal/match_data.rb, line 46
def my_score
  send("score_#{side}")
end
other_positions() click to toggle source
# File lib/rubygoal/match_data.rb, line 58
def other_positions
  send("#{other_side}_players_positions")
end
other_score() click to toggle source
# File lib/rubygoal/match_data.rb, line 50
def other_score
  send("score_#{other_side}")
end
other_side() click to toggle source
# File lib/rubygoal/match_data.rb, line 42
def other_side
  side == :home ? :away : :home
end
remove_goalkeeper_position(positions) click to toggle source
# File lib/rubygoal/match_data.rb, line 28
def remove_goalkeeper_position(positions)
  positions.tap do |ps|
    ps.delete(:goalkeeper)
  end
end