Class: Sportradar::Api::Soccer::Lineup

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/soccer/lineup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data

Constructor Details

#initialize(data, **opts) ⇒ Lineup

Returns a new instance of Lineup.



7
8
9
10
11
12
13
14
15
# File 'lib/sportradar/api/soccer/lineup.rb', line 7

def initialize(data, **opts)
  @response     = data
  @id           = data["team"]

  @starting_hash  = {}
  @subs_hash      = {}

  update(data, **opts)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/soccer/lineup.rb', line 5

def id
  @id
end

#jerseyObject (readonly)

Returns the value of attribute jersey.



5
6
7
# File 'lib/sportradar/api/soccer/lineup.rb', line 5

def jersey
  @jersey
end

#managerObject (readonly)

Returns the value of attribute manager.



5
6
7
# File 'lib/sportradar/api/soccer/lineup.rb', line 5

def manager
  @manager
end

#starting_lineupObject (readonly)

Returns the value of attribute starting_lineup.



5
6
7
# File 'lib/sportradar/api/soccer/lineup.rb', line 5

def starting_lineup
  @starting_lineup
end

#substitutesObject (readonly)

Returns the value of attribute substitutes.



5
6
7
# File 'lib/sportradar/api/soccer/lineup.rb', line 5

def substitutes
  @substitutes
end

#teamObject (readonly)

Returns the value of attribute team.



5
6
7
# File 'lib/sportradar/api/soccer/lineup.rb', line 5

def team
  @team
end

Instance Method Details

#update(data, **opts) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/sportradar/api/soccer/lineup.rb', line 16

def update(data, **opts)
  @team     = data['team']                    if data['team']
  @manager  = OpenStruct.new(data['manager']) if data['manager']
  @jersey   = OpenStruct.new(data['jersey'])  if data['jersey']
  # @starting_lineup  = data['starting_lineup'] if data['starting_lineup']
  # @substitutes      = data['substitutes']     if data['substitutes']

  create_data(@starting_hash, data['starting_lineup'], klass: Player, api: opts[:api], lineup: self) if data['starting_lineup']
  create_data(@subs_hash,     data['substitutes'],     klass: Player, api: opts[:api], lineup: self) if data['substitutes']
end