Class: GameLockerAPI::AbstractParser
- Inherits:
-
Object
- Object
- GameLockerAPI::AbstractParser
- Defined in:
- lib/gamelocker_api/abstract_parser.rb
Class Method Summary collapse
- .guess(end_point, data) ⇒ Object
-
.match(data, solo = false) ⇒ Object
Might only work with MATCHES…
-
.participant(roster) ⇒ Object
Expects a roster uuid.
- .player(data, solo = false) ⇒ Object
- .roster(data) ⇒ Object
Class Method Details
.guess(end_point, data) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gamelocker_api/abstract_parser.rb', line 3 def self.guess(end_point, data) if end_point == "matches" match(data) elsif end_point.start_with?("matches/") match(data, true) elsif end_point == "players" player(data) elsif end_point.start_with?("players/") player(data, true) else raise "(0_-)\nCouldn't guess what parser to use, sorry.\nEndpoint was: #{end_point}" end end |
.match(data, solo = false) ⇒ Object
Might only work with MATCHES… []
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gamelocker_api/abstract_parser.rb', line 20 def self.match(data, solo = false) _matches = [] temp_match = nil if solo temp_match = Match.new(data) else data['data'].each_with_index do |m, i| temp_match = Match.new(data, i) # Need to pass index _matches.push(temp_match) end end solo ? temp_match : _matches end |
.participant(roster) ⇒ Object
Expects a roster uuid
53 54 |
# File 'lib/gamelocker_api/abstract_parser.rb', line 53 def self.participant(roster) end |
.player(data, solo = false) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gamelocker_api/abstract_parser.rb', line 34 def self.player(data, solo = false) temp_players = [] temp_player = nil unless solo data['data'].each do |local_player| temp_player = Player.new(local_player) temp_players.push(temp_player) end else temp_player = Player.new(data['data']) end solo ? temp_player : temp_players end |
.roster(data) ⇒ Object
49 50 |
# File 'lib/gamelocker_api/abstract_parser.rb', line 49 def self.roster(data) end |