Class: Client
- Inherits:
-
Object
- Object
- Client
- Defined in:
- lib/client.rb
Overview
Encapsulate all the main functionality and represents the client using the user database and Yummly API
Instance Method Summary collapse
-
#last ⇒ Object
Provides the last recipe of logged user.
-
#login(email, password) ⇒ Object
Login the user using Backendless.
-
#recipe(parameters) ⇒ Object
Provides the recipe for the logged user according to his level and searching parameters.
-
#register(email, password) ⇒ Object
Register the user using Backendless.
-
#review(rating) ⇒ Object
Reviews the cooked food of the last recipe of logged user.
-
#user ⇒ Object
Provides the stats of the user.
Instance Method Details
#last ⇒ Object
Provides the last recipe of logged user
37 38 39 40 41 42 43 |
# File 'lib/client.rb', line 37 def last user = User.new user.read_creddentials user.login last_food = YumConnector.food_by_id user.last puts last_food.to_str end |
#login(email, password) ⇒ Object
Login the user using Backendless
31 32 33 34 |
# File 'lib/client.rb', line 31 def login(email, password) user = User.new puts user.login email, password end |
#recipe(parameters) ⇒ Object
Provides the recipe for the logged user according to his level and searching parameters
8 9 10 11 12 13 14 15 16 |
# File 'lib/client.rb', line 8 def recipe(parameters) user = User.new user.read_creddentials user.login generated_food = YumConnector.search parameters, user.xp abort("Sorry, I can't find food for you like that") if generated_food.nil? user.update_last_food_id generated_food.id puts generated_food.to_str end |
#register(email, password) ⇒ Object
Register the user using Backendless
22 23 24 25 |
# File 'lib/client.rb', line 22 def register(email, password) user = User.new puts user.register email, password end |
#review(rating) ⇒ Object
Reviews the cooked food of the last recipe of logged user
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/client.rb', line 46 def review() user = User.new user.read_creddentials user.login response = user.review if response puts 'Last food reviewed!' else puts 'Nothing to review' end end |
#user ⇒ Object
Provides the stats of the user
59 60 61 62 63 64 |
# File 'lib/client.rb', line 59 def user user = User.new user.read_creddentials user.login puts user.to_str end |