Class: Rack::SpySatelite

Inherits:
Object
  • Object
show all
Defined in:
lib/spy-satelite.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, args) ⇒ SpySatelite

Returns a new instance of SpySatelite.



5
6
7
8
9
10
11
12
13
# File 'lib/spy-satelite.rb', line 5

def initialize(app, args)
        
  Pusher.app_id = args[:id]
  Pusher.key    = args[:key]
  Pusher.secret = args[:secret]
  
  @cities = [[57.0, -2.0], [-34.0, 138.0], [36.0, 3.0], [52.0, 4.0], [39.0, 32.0], [-25.0, -57.0], [37.0, 23.0], [-36.0, 174.0], [13.0, 100.0], [41.0, 2.0], [39.0, 116.0], [-1.0, -48.0], [54.0, -5.0], [44.0, 20.0], [52.0, 13.0], [52.0, -1.0], [4.0, -74.0], [19.0, 72.0], [44.0, -0.0], [53.0, 8.0], [-27.0, 153.0], [51.0, -2.0], [50.0, 4.0], [44.0, 26.0], [47.0, 19.0], [-34.0, -58.0], [30.0, 31.0], [22.0, 88.0], [23.0, 113.0], [-33.0, 18.0], [10.0, -67.0], [4.0, -52.0], [28.0, -106.0], [29.0, 106.0], [55.0, 12.0], [-31.0, -64.0], [14.0, -17.0], [-12.0, 130.0], [11.0, 43.0], [53.0, -6.0], [-29.0, 30.0], [55.0, -3.0], [50.0, 8.0], [6.0, -58.0], [55.0, -4.0], [14.0, -90.0], [-2.0, -79.0], [53.0, 10.0], [70.0, 23.0], [23.0, -82.0], [60.0, 25.0], [-42.0, 147.0], [22.0, 114.0], [-20.0, -70.0], [52.0, 104.0], [-6.0, 106.0], [-26.0, 28.0], [17.0, -76.0], [-4.0, 15.0], [3.0, 101.0], [-16.0, -68.0], [53.0, -1.0], [-12.0, -77.0], [38.0, -9.0], [53.0, -3.0], [51.0, -0.0], [45.0, 4.0], [40.0, -3.0], [53.0, -2.0], [14.0, 120.0], [43.0, 5.0], [23.0, -106.0], [21.0, 39.0], [-37.0, 144.0], [19.0, -99.0], [45.0, 9.0], [-34.0, -56.0], [55.0, 37.0], [48.0, 11.0], [32.0, 129.0], [35.0, 136.0], [-1.0, 36.0], [32.0, 118.0], [40.0, 14.0], [28.0, 77.0], [54.0, -1.0], [46.0, 30.0], [34.0, 135.0], [59.0, 10.0], [8.0, -79.0], [5.0, -55.0], [48.0, 2.0], [-31.0, 115.0], [50.0, -4.0], [-9.0, 147.0], [50.0, 14.0], [16.0, 96.0], [64.0, -21.0], [-22.0, -43.0], [41.0, 12.0], [-12.0, -38.0], [-33.0, -70.0], [59.0, 30.0], [-23.0, -46.0], [31.0, 121.0], [1.0, 103.0], [42.0, 23.0], [59.0, 18.0], [-34.0, 151.0], [-18.0, 47.0], [35.0, 51.0], [35.0, 139.0], [32.0, 13.0], [45.0, 12.0], [19.0, -96.0], [48.0, 16.0], [43.0, 132.0], [52.0, 21.0], [-41.0, 174.0], [47.0, 8.0]] 
  @app = app       
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/spy-satelite.rb', line 15

def call(env)
  city = @cities[rand(@cities.length)]
  lat = city.first
  long = city.last
  Pusher['visitors'].trigger('new-visit', {:lat => lat, :long => long})
  @app.call(env)   
end