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.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



7
8
9
# File 'lib/hyperfocal.rb', line 7

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



9
10
11
12
# File 'lib/hyperfocal.rb', line 9

def configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

.event(event, attrs = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/hyperfocal.rb', line 20

def event(event, attrs = {})
  send_request do
    event_params = { event: attrs.merge(title: event) }
    Transmitter.send('event', event_params)
  end
end

.hostObject



14
15
16
17
18
# File 'lib/hyperfocal.rb', line 14

def host
  raise 'App ID Not Set' if configuration.app_id.nil?

  configuration.host + '/track/' + configuration.app_id
end

.metric(metric, value, attrs = {}) ⇒ Object



27
28
29
30
31
32
# File 'lib/hyperfocal.rb', line 27

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



41
42
43
44
45
46
47
# File 'lib/hyperfocal.rb', line 41

def send_request(&block)
  thr = Thread.new do
    yield
  end
  thr.join
  thr.exit
end

.user(attrs) ⇒ Object



34
35
36
37
38
39
# File 'lib/hyperfocal.rb', line 34

def user(attrs)
  send_request do
    user_params = { user: attrs }
    Transmitter.send('user', user_params)
  end
end