Guest User

Untitled

a guest
Feb 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. # for some reason the closure doesn't have access to class variables
  2. lon = params[:x]; lat = params[:y]; zoom = params[:zoom]; city = current_quest.city.code;
  3. width = params[:width].to_f; height = params[:height].to_f
  4. current_quest.primary_window = GeoLocation.new do
  5. # self.lon = params[:x]; self.lat = params[:y]; self.zoom = params[:zoom]
  6. puts "width: #{width}"
  7. puts "lat: #{lat}"
  8. self.lon = lon; self.lat = lat;
  9. self.width = width; self.height = height;
  10. self.zoom = zoom; self.city = city
  11. end
  12. puts "LAT: #{current_quest.primary_window.lat}"
  13. puts "WIDTH: #{current_quest.primary_window.width}"
  14. current_quest.save unless current_quest.anonymous?
  15.  
  16. class GeoLocation
  17. attr_accessor :lon, :lat, :width, :height, :zoom, :zip, :city, :state, :zip,
  18. :precision, :dist_from_home, :string_as_geocoded, :geo_postal, :geo_street_address, :geo_city, :geo_state
  19. def initialize(&block)
  20. instance_eval(&block)
  21. end
  22. ...
  23. end
  24.  
  25.  
  26. Output:
  27. width: 0.316406250000023
  28. lat: 37.754972691904946
  29. LAT: 37.754972691904946
  30. WIDTH:
Add Comment
Please, Sign In to add comment