Class: Sportradar::Api::Soccer::Standing
- Defined in:
- lib/sportradar/api/soccer/standing.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#league_group ⇒ Object
readonly
Returns the value of attribute league_group.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #api ⇒ Object
-
#group(name = nil) ⇒ Object
nil represents the complete team listing.
- #groups(name = nil) ⇒ Object
-
#initialize(data = {}, league_group: nil, **opts) ⇒ Standing
constructor
A new instance of Standing.
- #team(id) ⇒ Object
- #teams ⇒ Object
- #update(data, **opts) ⇒ Object
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 = {}, league_group: nil, **opts) ⇒ Standing
Returns a new instance of Standing.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sportradar/api/soccer/standing.rb', line 7 def initialize(data = {}, league_group: nil, **opts) @response = data @id = data["id"] || data['type'] @api = opts[:api] @league_group = league_group || data['league_group'] || @api&.league_group @groups_hash = {} update(data, **opts) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/soccer/standing.rb', line 5 def id @id end |
#league_group ⇒ Object (readonly)
Returns the value of attribute league_group.
5 6 7 |
# File 'lib/sportradar/api/soccer/standing.rb', line 5 def league_group @league_group end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/sportradar/api/soccer/standing.rb', line 5 def type @type end |
Instance Method Details
#api ⇒ Object
43 44 45 |
# File 'lib/sportradar/api/soccer/standing.rb', line 43 def api @api ||= Sportradar::Api::Soccer::Api.new(league_group: @league_group) end |
#group(name = nil) ⇒ Object
nil represents the complete team listing
31 32 33 |
# File 'lib/sportradar/api/soccer/standing.rb', line 31 def group(name = nil) # nil represents the complete team listing @groups_hash[name] end |
#groups(name = nil) ⇒ Object
27 28 29 |
# File 'lib/sportradar/api/soccer/standing.rb', line 27 def groups(name = nil) @groups_hash.values end |
#team(id) ⇒ Object
39 40 41 |
# File 'lib/sportradar/api/soccer/standing.rb', line 39 def team(id) @groups_hash.values.flat_map(&:teams).detect { |team| team.id == id } end |
#teams ⇒ Object
35 36 37 |
# File 'lib/sportradar/api/soccer/standing.rb', line 35 def teams @groups_hash.values.flat_map(&:teams) end |
#update(data, **opts) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/sportradar/api/soccer/standing.rb', line 18 def update(data, **opts) @type = data['type'] @tie_break_rule = data['tie_break_rule'] if data['tie_break_rule'] if data['groups'] create_data(@groups_hash, data['groups'], klass: TeamGroup, api: api, identifier: 'name') end end |