infostrada 0.1.24 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzE3NDBiNmMwMWIwNWI4ZTYzZDA0Y2UzMWI1OGZjYmVhMDMyMTM2NA==
4
+ NjU1YWFhNjRmN2NkNGJhMjAyZTk5NGRmMzNjNTg0ZmE3NWJlMzI3Ng==
5
5
  data.tar.gz: !binary |-
6
- NmZmZDE4MzNiNjIzMmUxZDkyNzFjNGY1MTQwYjNmOTQyMGVjN2U4YQ==
6
+ MDllZmQwOGVkM2M2ZDdkNDdlOWE1YjgzMjI0ZjI4NGYwODhjNDRjNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjM2NTY1MWU1YmJkMjY4MTIyYTYxYTUxMzk2Y2M3YmVkNjQ3N2ZlOTE3MjZh
10
- YTY5MTNjOWQ5YjE1NGE3ODAxYTMzZjQzMjJhMDQxYmE1ZTc3MjdhNGRhMTk2
11
- ZWI4YTk4ZTNjZjNhN2VmYzdmMDRiOWY2MDRkM2QzZGNhMWFjOTA=
9
+ Yjg4MzkwMjFjZGRmOWRkN2ZkZjEyZjVmMWIyOGYxODFlOGVlZDkzZTkwZjMx
10
+ MDg5MTNhODE4MTM1NTMzNGM5MTdmMDE3MTQ2OTk3Mzk3ZThhZDc2ZDlhOGUw
11
+ MmZkMTljY2RlOWU4Y2E2ZDNiNTlmYmQwODBmNDA0MmMyYzU3Mzk=
12
12
  data.tar.gz: !binary |-
13
- ZjQxNjgyZjQxMTJjZmM4NzdjMjQzYjExODgxZjFkODkyM2MxMjE0NzMzMGY2
14
- NDEyM2UwNjkwNTc4YjQ5M2I5YjZlMWU3OWJlNmZmMTI0YmMyNzMxOTY2ZGIz
15
- NDViZGUxOWM4MjQ1M2UyZmJiZjQxNDAyZTdkZDMzYzRkZjRlNmQ=
13
+ MDZmNTc0NDJmMTlhMTUxMGZmZTg1ZDBhNDcwMjIwNGRjNzhmMzgyMGZjNmYx
14
+ YzUyNjE3YTJmMzIwMTQxZjExZmE0YzFlMDFiNzVhMmZmODJlMmUzZjM3N2Ji
15
+ M2MxYTI3NTZhOTMyNzJlM2RiZjU2ZTI1MGQyZDZiMDEwZTI4MTg=
@@ -16,7 +16,7 @@ module Infostrada
16
16
 
17
17
  attr_accessor :id, :date, :rescheduled, :round, :home_team, :away_team, :phase, :status_short
18
18
  attr_accessor :stadium_id, :stadium_name, :goals, :match_status, :finished, :awarded
19
- attr_accessor :postponed, :referee, :spectators, :leg, :knockout_phase, :first_leg_score
19
+ attr_accessor :postponed, :referee, :spectators, :leg, :knockout_phase_id, :first_leg_score
20
20
  attr_accessor :aggregate_winner_id, :current_period_started_at, :status, :started_at, :started
21
21
  attr_accessor :edition, :time_unknown, :date_unknown, :city
22
22
 
@@ -120,6 +120,7 @@ module Infostrada
120
120
  match.status_short = json['status_short']
121
121
  match.leg = json['leg']
122
122
  match.started_at = Time.parse(json['started_at']) if json['started_at']
123
+ match.knockout_phase_id = hash['knockout_phase_id']
123
124
 
124
125
  match.stadium_id = json['stadium_id']
125
126
  match.stadium_name = json['stadium_name']
@@ -164,6 +165,7 @@ module Infostrada
164
165
  @status_short = hash['c_MatchStatusShort']
165
166
  @leg = hash['n_Leg']
166
167
  @started_at = Formatter.format_date(hash['d_MatchStartTime'])
168
+ @knockout_phase_id = hash['n_KnockoutPhaseID']
167
169
 
168
170
  @stadium_id = hash['n_StadiumGeoID']
169
171
  @stadium_name = hash['c_Stadium']
@@ -8,13 +8,20 @@ module Infostrada
8
8
 
9
9
  def self.where(options = {})
10
10
  phase_id = options.delete(:phase_id)
11
-
12
11
  list = get!(URL, query: { phaseid: phase_id })
13
12
 
14
- table = Table.new(phase_id, list)
13
+ new(phase_id, list)
15
14
  end
16
15
 
17
- def initialize(phase_id, table_list)
16
+ def self.from_json(json = {})
17
+ self.new do |table|
18
+ table.phase_id = json['phase_id']
19
+ table.edition_id = json['edition_id']
20
+ table.entries = json['entries'].map{ |entry| TableEntry.from_json(entry) }
21
+ end
22
+ end
23
+
24
+ def initialize(phase_id = nil, table_list = [], &block)
18
25
  @phase_id = phase_id
19
26
 
20
27
  @entries = []
@@ -23,12 +30,13 @@ module Infostrada
23
30
  @entries << TableEntry.new(hash)
24
31
  end
25
32
 
33
+ block.call(self) if block_given?
26
34
  self
27
35
  end
28
36
 
29
- def as_json
37
+ def as_json(options)
30
38
  hash = super
31
- hash = { 'phase_id' => phase_id, 'entries' => hash }
39
+ hash = { 'phase_id' => phase_id, 'edition_id' => edition_id, 'entries' => hash }
32
40
  end
33
41
 
34
42
  def each(&block)
@@ -40,7 +48,21 @@ module Infostrada
40
48
  attr_accessor :team_id, :rank, :matches, :matches_won, :matches_drawn
41
49
  attr_accessor :matches_lost, :points, :goals_for, :goals_against
42
50
 
43
- def initialize(hash)
51
+ def self.from_json(json = {})
52
+ self.new do |table_entry|
53
+ table_entry.team_id = json['team_id']
54
+ table_entry.rank = json['rank']
55
+ table_entry.matches = json['matches']
56
+ table_entry.matches_won = json['matches_won']
57
+ table_entry.matches_drawn = json['matches_drawn']
58
+ table_entry.matches_lost = json['matches_lost']
59
+ table_entry.points = json['points']
60
+ table_entry.goals_for = json['goals_for']
61
+ table_entry.goals_against = json['goals_against']
62
+ end
63
+ end
64
+
65
+ def initialize(hash = {}, &block)
44
66
  @team_id = hash['n_TeamID']
45
67
  @rank = hash['n_RankSort']
46
68
  @matches = hash['n_Matches']
@@ -50,6 +72,9 @@ module Infostrada
50
72
  @points = hash['n_Points']
51
73
  @goals_for = hash['n_GoalsFor']
52
74
  @goals_against = hash['n_GoalsAgainst']
75
+
76
+ block.call(self) if block_given?
77
+ self
53
78
  end
54
79
  end
55
80
  end
@@ -1,3 +1,3 @@
1
1
  module Infostrada
2
- VERSION = '0.1.24'
2
+ VERSION = '0.1.25'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infostrada
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler