Commit 123d87c
Changed files (5)
app
app/controllers/location_controller.rb → app/controllers/restaurant_controller.rb
@@ -1,7 +1,7 @@
-class LocationController < UIViewController
+class RestaurantController < UIViewController
def viewDidLoad
super
- self.title = "Location"
+ self.title = "Restaurant"
self.view.backgroundColor = UIColor.whiteColor
@text_field = UITextField.alloc.initWithFrame [[0,0], [160, 26]]
@@ -13,7 +13,7 @@ class LocationController < UIViewController
self.view.addSubview @text_field
@add = UIButton.buttonWithType(UIButtonTypeRoundedRect)
- @add.setTitle("Add Location", forState:UIControlStateNormal)
+ @add.setTitle("Add Restaurant", forState:UIControlStateNormal)
@add.setTitle("Loading", forState:UIControlStateDisabled)
@add.sizeToFit
@add.center = CGPointMake(self.view.frame.size.width / 2, @text_field.center.y + 40)
@@ -22,7 +22,7 @@ class LocationController < UIViewController
@add.enabled = false
@text_field.enabled = false
p @text_field.text
- location = Location.new(@text_field.text, 1, 1)
+ location = Restaurant.new(@text_field.text, 1, 1)
location.save
end
app/models/location.rb
@@ -1,19 +0,0 @@
-class Location
- attr_accessor :name, :latitude, :longitude
-
- def initialize(name, latitude, longitude)
- @name = name
- @latitude = latitude
- @longitude = longitude
- end
-
- def save
- begin
- BW::HTTP.post("http://localhost:3000/api/v1/restaurants", payload: { restaurant: { name: @name, latitude: @latitude, longitude: @longitude } } ) do |response|
- p response
- end
- rescue Exception => e
- p e
- end
- end
-end
app/models/restaurant.rb
@@ -0,0 +1,27 @@
+class Restaurant
+ attr_accessor :name, :latitude, :longitude
+
+ def initialize(name, latitude, longitude)
+ @name = name
+ @latitude = latitude
+ @longitude = longitude
+ end
+
+ def save
+
+
+
+
+ begin
+ BW::HTTP.post("http://localhost:3000/api/v1/restaurants", payload: { restaurant: { name: @name, latitude: @latitude, longitude: @longitude } } ) do |response|
+ begin
+ p response
+ rescue Exception => e
+ p e
+ end
+ end
+ rescue Exception => e
+ p e
+ end
+end
+end
app/app_delegate.rb
@@ -1,7 +1,18 @@
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
+ begin
+ BW::Location.get do |result|
+ p "LOCATION: #{result}"
+ p result
+ #p "From Lat #{result[:from].latitude}, Long #{result[:from].longitude}"
+ #p "To Lat #{result[:to].latitude}, Long #{result[:to].longitude}"
+ end
+ rescue Exception => e
+ p e
+ end
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
- @location_controller = LocationController.alloc.initWithNibName(nil, bundle:nil)
+ @location_controller = RestaurantController.alloc.initWithNibName(nil, bundle:nil)
@navigation_controller = UINavigationController.alloc.initWithRootViewController(@location_controller)
@window.rootViewController = @navigation_controller
Rakefile
@@ -3,6 +3,7 @@ $:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'bundler'
Bundler.require
+require 'bubble-wrap/location'
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.