-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesdb.rb
More file actions
52 lines (46 loc) · 1.09 KB
/
esdb.rb
File metadata and controls
52 lines (46 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module ESDB
class Exception < Exception; end
# Various Settings
# TODO: refactor
class << self
def api_key=(key)
@api_key = key
end
def api_key
@api_key
end
end
# Simply transforms a stats hash into a StatsParam string
class StatsParam
def initialize(stats)
@array = []
@stats = stats
stats.each do |key, value|
if value.is_a?(Array)
values = value.join(',')
elsif value === true
values = 'avg'
elsif value.is_a?(Hash)
values = value.collect{|calc, conds|
if conds.collect(&:class).include?(Array)
conds.collect{|_conds| "#{calc}#{":[#{_conds.join(',')}]" if _conds.is_a?(Array)}"}.join(',')
else
"#{calc}:[#{conds.join(',')}]"
end
}.join(',')
else
values = value
end
@array << "#{key}(#{values})"
end
end
def to_s
@array.join(',')
end
end
end
require 'esdb/resource'
require 'esdb/identity'
require 'esdb/stat'
require 'esdb/replay'
require 'esdb/match'