Back to Parent

elsif body.start_with? "get"
    arr = [body]
    date_string = arr.map{ |s| s.gsub("get ", "").gsub(" "," ") }[0]
    date = Chronic.parse(date_string).to_date
    recording = Journal.find_by(created_time: date)
    mood = recording.mood
    activity = recording.activity
    note = recording.note
    if recording.mood.to_i.between?(1, 5)
      moods = ["Wonderful😊", "Good🙂", "Meh😐", "Bad😞", "Awful😣"]
      mood_index = recording.mood.to_i
      mood = moods[mood_index-1]
    end
    if recording.activity.to_i.between?(1, 10)
      activities = ["work/study💻", "relax☕️", "friends🤼‍♀️", "date💕", "sport🏋", "party🍻", "movies🎥", "reading📖", "gaming🎮", "travel✈️"]
      activity_index = recording.activity.to_i
      activity = activities[activity_index-1]
    end
    message = "Mood: #{mood} \nActivity: #{activity} \nNote: #{note} \n#{date}"
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0