Skip to content

Commit 46ed119

Browse files
committed
added Match#map and Match#summaries?
1 parent fd16581 commit 46ed119

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

gg.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
1313
s.description = ""
1414

1515
s.add_dependency('rest-client')
16+
s.add_dependency('hashie')
1617
s.add_dependency('yajl-ruby')
1718

1819
# Because I just don't want to live without some of it..

lib/esdb/match.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
module ESDB
22
class Match < ESDB::Resource
3+
# HAX
4+
# Does the match have any summary data?
5+
def summaries?
6+
hash = self.to_hash
7+
if hash['entities'].any?
8+
summaries = hash['entities'].collect{|e| e['summary']}
9+
return summaries.reject{|s| s.empty? || s.nil?}.any?
10+
end
11+
false
12+
end
13+
14+
# TODO: when there is ample time, I want to generalize stuff like this via
15+
# something like Hashie, but Hashie::Mash just didn't work out right away
16+
# it's complicated.. the fact that we have a key called "map" alone..
17+
def map
18+
Hashie::Mash.new(self.to_hash['map'])
19+
end
20+
321
# Combines all entities into a hash keys with the team number
422
def teams
523
entities.inject({}){|teams, entity|

lib/gg.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def self.config
2020
end
2121

2222
require 'rest_client'
23+
require 'hashie/mash'
2324
require 'active_support/inflector'
2425
require 'yajl'
2526
require 'yajl/json_gem'

0 commit comments

Comments
 (0)