Class: Gecko::Pusher::Channel::Map

Inherits:
Base
  • Object
show all
Defined in:
lib/gecko-pusher/channel/map.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gecko::Pusher::Channel::Base

Instance Method Details

#push(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gecko-pusher/channel/map.rb', line 6

def push(*args)
  data = args.map {|arg|
    point_data, options = if arg.is_a?(Array) &&
                            arg.length == 2 &&
                            arg.last.is_a?(Hash)
                            [arg.first, check_options(arg.last)]
                          else
                            [arg, {}]
                          end

    if ip_address?(point_data)
      {ip: point_data}.merge(options)
    elsif lat_long?(point_data)
      {latitude: point_data[0].to_s, longitude: point_data[1].to_s}.merge(options)
    elsif address?(point_data)
      {city: point_data}.merge(options)
    elsif hostname?(point_data)
      {host: point_data}.merge(options)
    end
  }

  _push({points: { point: data}})
end