Class: Infostrada::MatchEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/infostrada/match_event.rb

Overview

MatchEvent can have a lot of different events in a match.

Here’s a list of the n_ActionSet values, from Infostrada FAQ:

1 = Goals 2 = Penalty shootout 3 = Cards 4 = Line-up 5 = Substitutions 6 = Substitutes not used 7 = Players not selected / suspended 8 = Coaches 9 = Officials 10 = Missed penalties 11 = Captain 12 = Free kick / Foul / Corner / Offside / Shot / Save 13 = Possession 14 = Temporarily out 15 = Other 16 = Time

period_code is taken from Infostradas n_PeriodSort, that can have one of these values:

1 = Not started 2 = 1st Half 3 = Halftime 4 = 2nd Half 5 = 90 mins 6 = 1st Extra Time 7 = 105 mins 8 = 2nd Extra Time 9 = 120 mins 10 = Penalty Shootout 11 = End

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match_id = nil, hash = {}, &block) ⇒ MatchEvent

Returns a new instance of MatchEvent.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/infostrada/match_event.rb', line 78

def initialize(match_id = nil, hash = {}, &block)
  @match_id           = match_id
  @id                 = hash['n_ActionID']
  @description        = hash['c_Action']
  @short_description  = hash['c_ActionShort']
  @period             = hash['c_Period']
  @period_short       = hash['c_PeriodShort']
  @period_code        = hash['n_PeriodSort']
  @time               = hash['n_ActionTime']
  @home_goals         = hash['n_HomeGoals']
  @away_goals         = hash['n_AwayGoals']
  @home_event         = hash['n_HomeOrAway'] == 1
  @team_id            = hash['n_TeamID']
  @team_name          = hash['c_Team']
  @team_short_name    = hash['c_TeamShort']
  @person_id          = hash['n_PersonID']
  @person_name        = hash['c_Person']
  @person_short_name  = hash['c_PersonShort']
  @reason             = hash['c_ActionReason']
  @info               = hash['c_ActionInfo']
  @person2_id         = hash['n_SubPersonID']
  @person2_name       = hash['c_SubPerson']
  @person2_short_name = hash['c_SubPersonShort']
  @minute             = hash['c_ActionMinute']
  @action_set         = hash['n_ActionSet']
  @action_code        = hash['n_ActionCode']
  @action_code_2      = hash['n_ActionCode2']
  @action_code_3      = hash['n_ActionCode3']
  @action_sort        = hash['n_ActionSort']

  block.call(self) if block_given?
  self
end

Instance Attribute Details

#action_codeObject

These action codes are documented on the Infostrada ADVANCED PROGRAMMING documentation



43
44
45
# File 'lib/infostrada/match_event.rb', line 43

def action_code
  @action_code
end

#action_code_2Object

These action codes are documented on the Infostrada ADVANCED PROGRAMMING documentation



43
44
45
# File 'lib/infostrada/match_event.rb', line 43

def action_code_2
  @action_code_2
end

#action_code_3Object

These action codes are documented on the Infostrada ADVANCED PROGRAMMING documentation



43
44
45
# File 'lib/infostrada/match_event.rb', line 43

def action_code_3
  @action_code_3
end

#action_setObject

Returns the value of attribute action_set.



40
41
42
# File 'lib/infostrada/match_event.rb', line 40

def action_set
  @action_set
end

#action_sortObject

Returns the value of attribute action_sort.



40
41
42
# File 'lib/infostrada/match_event.rb', line 40

def action_sort
  @action_sort
end

#away_goalsObject

Returns the value of attribute away_goals.



38
39
40
# File 'lib/infostrada/match_event.rb', line 38

def away_goals
  @away_goals
end

#descriptionObject

Returns the value of attribute description.



37
38
39
# File 'lib/infostrada/match_event.rb', line 37

def description
  @description
end

#home_eventObject

Returns the value of attribute home_event.



38
39
40
# File 'lib/infostrada/match_event.rb', line 38

def home_event
  @home_event
end

#home_goalsObject

Returns the value of attribute home_goals.



37
38
39
# File 'lib/infostrada/match_event.rb', line 37

def home_goals
  @home_goals
end

#idObject

Returns the value of attribute id.



37
38
39
# File 'lib/infostrada/match_event.rb', line 37

def id
  @id
end

#infoObject

Returns the value of attribute info.



39
40
41
# File 'lib/infostrada/match_event.rb', line 39

def info
  @info
end

#match_idObject

Returns the value of attribute match_id.



40
41
42
# File 'lib/infostrada/match_event.rb', line 40

def match_id
  @match_id
end

#minuteObject

Returns the value of attribute minute.



40
41
42
# File 'lib/infostrada/match_event.rb', line 40

def minute
  @minute
end

#periodObject

Returns the value of attribute period.



37
38
39
# File 'lib/infostrada/match_event.rb', line 37

def period
  @period
end

#period_codeObject

Returns the value of attribute period_code.



40
41
42
# File 'lib/infostrada/match_event.rb', line 40

def period_code
  @period_code
end

#period_shortObject

Returns the value of attribute period_short.



37
38
39
# File 'lib/infostrada/match_event.rb', line 37

def period_short
  @period_short
end

#person2_idObject

Returns the value of attribute person2_id.



39
40
41
# File 'lib/infostrada/match_event.rb', line 39

def person2_id
  @person2_id
end

#person2_nameObject

Returns the value of attribute person2_name.



39
40
41
# File 'lib/infostrada/match_event.rb', line 39

def person2_name
  @person2_name
end

#person2_short_nameObject

Returns the value of attribute person2_short_name.



40
41
42
# File 'lib/infostrada/match_event.rb', line 40

def person2_short_name
  @person2_short_name
end

#person_idObject

Returns the value of attribute person_id.



38
39
40
# File 'lib/infostrada/match_event.rb', line 38

def person_id
  @person_id
end

#person_nameObject

Returns the value of attribute person_name.



39
40
41
# File 'lib/infostrada/match_event.rb', line 39

def person_name
  @person_name
end

#person_short_nameObject

Returns the value of attribute person_short_name.



39
40
41
# File 'lib/infostrada/match_event.rb', line 39

def person_short_name
  @person_short_name
end

#reasonObject

Returns the value of attribute reason.



39
40
41
# File 'lib/infostrada/match_event.rb', line 39

def reason
  @reason
end

#short_descriptionObject

Returns the value of attribute short_description.



37
38
39
# File 'lib/infostrada/match_event.rb', line 37

def short_description
  @short_description
end

#team_idObject

Returns the value of attribute team_id.



38
39
40
# File 'lib/infostrada/match_event.rb', line 38

def team_id
  @team_id
end

#team_nameObject

Returns the value of attribute team_name.



38
39
40
# File 'lib/infostrada/match_event.rb', line 38

def team_name
  @team_name
end

#team_short_nameObject

Returns the value of attribute team_short_name.



38
39
40
# File 'lib/infostrada/match_event.rb', line 38

def team_short_name
  @team_short_name
end

#timeObject

Returns the value of attribute time.



37
38
39
# File 'lib/infostrada/match_event.rb', line 37

def time
  @time
end

Class Method Details

.from_json(hash = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/infostrada/match_event.rb', line 45

def self.from_json(hash = {})
  self.new do |event|
    event.match_id           = hash['match_id']
    event.id                 = hash['id']
    event.description        = hash['description']
    event.short_description  = hash['short_description']
    event.period             = hash['period']
    event.period_short       = hash['period_short']
    event.period_code        = hash['period_code']
    event.time               = hash['time']
    event.home_goals         = hash['home_goals']
    event.away_goals         = hash['away_goals']
    event.home_event         = hash['home_event']
    event.team_id            = hash['team_id']
    event.team_name          = hash['team_name']
    event.team_short_name    = hash['team_short_name']
    event.person_id          = hash['person_id']
    event.person_name        = hash['person_name']
    event.person_short_name  = hash['person_short_name']
    event.reason             = hash['reason']
    event.info               = hash['info']
    event.person2_id         = hash['person2_id']
    event.person2_name       = hash['person2_name']
    event.person2_short_name = hash['person2_short_name']
    event.minute             = hash['minute']
    event.action_set         = hash['action_set']
    event.action_code        = hash['action_code']
    event.action_code_2      = hash['action_code_2']
    event.action_code_3      = hash['action_code_3']
    event.action_sort        = hash['action_sort']
  end
end

Instance Method Details

#attributesObject



118
119
120
# File 'lib/infostrada/match_event.rb', line 118

def attributes
  instance_values
end

#attributes=(hash) ⇒ Object



112
113
114
115
116
# File 'lib/infostrada/match_event.rb', line 112

def attributes=(hash)
  hash.each do |key, value|
    send("#{key}=", value)
  end
end