Module: Hyperfocal
- Defined in:
- lib/hyperfocal.rb,
lib/hyperfocal/version.rb,
lib/hyperfocal/commands.rb,
lib/hyperfocal/transmitter.rb
Defined Under Namespace
Modules: Transmitter
Classes: Commands, Configuration
Constant Summary
collapse
- VERSION =
"0.2.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
7
8
9
|
# File 'lib/hyperfocal.rb', line 7
def configuration
@configuration
end
|
Class Method Details
9
10
11
12
13
|
# File 'lib/hyperfocal.rb', line 9
def configure
self.configuration ||= Configuration.new
yield(configuration)
configuration.host = 'https://api.hyperfocal.io'
end
|
.event(event, attrs = {}) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/hyperfocal.rb', line 21
def event(event, attrs = {})
send_request do
event_params = { event: attrs.merge(title: event) }
Transmitter.send('event', event_params)
end
end
|
.host ⇒ Object
15
16
17
18
19
|
# File 'lib/hyperfocal.rb', line 15
def host
raise 'App ID Not Set' if configuration.app_id.nil?
configuration.host + '/track/' + configuration.app_id
end
|
.metric(metric, value, attrs = {}) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/hyperfocal.rb', line 28
def metric(metric, value, attrs = {})
send_request do
metric_params = { metric: attrs.merge(title: metric, value: value) }
Transmitter.send('metric', metric_params)
end
end
|
.send_request(&block) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/hyperfocal.rb', line 42
def send_request(&block)
thr = Thread.new do
yield
end
thr.join
thr.exit
end
|
.user(attrs) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/hyperfocal.rb', line 35
def user(attrs)
send_request do
user_params = { user: attrs }
Transmitter.send('user', user_params)
end
end
|