Skip to content

Instantly share code, notes, and snippets.

@crystalneth
Created December 7, 2008 19:58
Show Gist options
  • Select an option

  • Save crystalneth/33233 to your computer and use it in GitHub Desktop.

Select an option

Save crystalneth/33233 to your computer and use it in GitHub Desktop.
# for some reason the closure doesn't have access to class variables
lon = params[:x]; lat = params[:y]; zoom = params[:zoom]; city = current_quest.city.code;
width = params[:width].to_f; height = params[:height].to_f
current_quest.primary_window = GeoLocation.new do
# self.lon = params[:x]; self.lat = params[:y]; self.zoom = params[:zoom]
puts "width: #{width}"
puts "lat: #{lat}"
self.lon = lon; self.lat = lat;
self.width = width; self.height = height;
self.zoom = zoom; self.city = city
end
puts "LAT: #{current_quest.primary_window.lat}"
puts "WIDTH: #{current_quest.primary_window.width}"
current_quest.save unless current_quest.anonymous?
class GeoLocation
attr_accessor :lon, :lat, :width, :height, :zoom, :zip, :city, :state, :zip,
:precision, :dist_from_home, :string_as_geocoded, :geo_postal, :geo_street_address, :geo_city, :geo_state
def initialize(&block)
instance_eval(&block)
end
...
end
Output:
width: 0.316406250000023
lat: 37.754972691904946
LAT: 37.754972691904946
WIDTH:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment