Class: BobModel
- Inherits:
-
Object
- Object
- BobModel
- Defined in:
- lib/dimibob/bob_model.rb
Overview
BobModel
Constant Summary collapse
- DIMIBOB_API_URL =
'http://dimigo.in/pages/dimibob_getdata.php?d='.freeze
Instance Method Summary collapse
- #breakfast ⇒ Object
- #dinner ⇒ Object
-
#initialize(date) ⇒ BobModel
constructor
A new instance of BobModel.
- #lunch ⇒ Object
- #meal ⇒ Object
- #snack ⇒ Object
Constructor Details
#initialize(date) ⇒ BobModel
Returns a new instance of BobModel.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dimibob/bob_model.rb', line 8 def initialize(date) meal_date = format('%04i%02i%02i', date.year, date.month, date.day) begin response = RestClient.get DIMIBOB_API_URL + meal_date @bob = JSON.parse(response.body) rescue @bob = { breakfast: 'Have No Data', lunch: 'Have No Data', dinner: 'Have No Data', snack: 'Have No Data' } end self end |
Instance Method Details
#breakfast ⇒ Object
29 30 31 |
# File 'lib/dimibob/bob_model.rb', line 29 def breakfast @bob['breakfast'].split('/') end |
#dinner ⇒ Object
37 38 39 |
# File 'lib/dimibob/bob_model.rb', line 37 def dinner @bob['dinner'].split('/') end |
#lunch ⇒ Object
33 34 35 |
# File 'lib/dimibob/bob_model.rb', line 33 def lunch @bob['lunch'].split('/') end |
#meal ⇒ Object
25 26 27 |
# File 'lib/dimibob/bob_model.rb', line 25 def meal @bob end |
#snack ⇒ Object
41 42 43 |
# File 'lib/dimibob/bob_model.rb', line 41 def snack @bob['snack'].split('/') end |