Class: Checkin

Inherits:
Object
  • Object
show all
Defined in:
lib/checkin.rb

Instance Method Summary collapse

Constructor Details

#initializeCheckin

Returns a new instance of Checkin.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/checkin.rb', line 2

def initialize
  el = EmotionList.new()

  @time = Time.now.strftime("%Y-%m-%d %H:%M:%S")

  observe_feeling
  @emotional_state = describe_feeling(el)
  @intensity = describe_feeling_instensity
  if @intensity > 5 and @emotional_state[:emotion] != "joy"
    @intervention = choose_intervention
    @trigger = describe_trigger
    case @intervention
    when "change"
      @note = change_self
    when "accept"
      @note = accept_self
    when "let go"
      @note = let_go_self
    else
      @note = nil
    end
  end
  close_checkin
end

Instance Method Details

#accept_selfObject



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/checkin.rb', line 96

def accept_self
  puts "Here are some things you might want to remind yourself about this trigger and your reaction to it:"
  puts "- It is as it is."
  puts "- I don’t have to agree with it or judge it as good or bad."
  puts "- I can always come back to this feeling later."
  puts "- I can keep my options open."
  puts "- This is a normal body reaction."
  puts "- I don’t have to fight it or try to stop it."
  puts "- It is as it is, but it won't stay that way. It will pass."
  puts
  puts "Jot down a thought about what accepting this means to you, so you can remember this later."
  return STDIN.gets.chomp
end

#breathing_exerciseObject

Breathing exercise to be run if the intensity of negative emotions is greater than 5



134
135
136
137
138
139
140
# File 'lib/checkin.rb', line 134

def breathing_exercise
  4.times do
    4.times { |n| puts "BREATHE IN  " + (">" * (n+1)) + ("." * (3-n)); sleep 1 }
    4.times { |n| puts "    HOLD    " + ("=" * 4); sleep 1 }
    4.times { |n| puts "BREATHE OUT " + ("<" * (4 - n)) + ("." * n); sleep 1 }
  end
end

#categorize_feeling(feeling, emotion_list) ⇒ Object

used to put the feeling that the user feels into terms readable for our databases



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/checkin.rb', line 149

def categorize_feeling(feeling, emotion_list)
  if feeling.downcase == "more"
    puts
    puts emotion_list
    puts
    puts "Pick a word from the list above that describes how you're feeling right now."
    return categorize_feeling(STDIN.gets.chomp, emotion_list)
  elsif emotion_list.list.keys.include?(feeling.downcase)
    # emotion named by user, but not a secondary state
    categorized = { emotion: feeling.downcase, state: nil }
  else
    matching_emotion = emotion_list.list.select {|emotion, states| states.include? feeling.downcase}
    categorized = { emotion: matching_emotion.keys[0], state: feeling.downcase }
  end
  return categorized if defined? categorized
  # User gave invalid input, run again
  return categorize_feeling("more", emotion_list)
end

#change_selfObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/checkin.rb', line 74

def change_self
  puts "Think about your environment, your situation, or your reactions. You can change each of those, even in small ways."
  puts
  puts "Think for a minute about what you want to change, and what you'd need to make that change."
  pause_for(25)
  puts "You probably aren't going to make this change all at once right now. But let's jot down some next steps you want to take in the near future. We'll store those away for after you've finished your work."
  puts
  puts "When you're done listing things you want to do later, type 'done'."
  tasks = get_tasks
  puts
  puts "Now before we move on, let's make a small change to your situation right now. Here are some ideas:"
  puts "- Take a quick exercise break."
  puts "- Go for a walk around the block."
  puts "- Clean up a part of this room right now, or your desk."
  puts "- Grab a healthy snack, or drink a glass of water."
  puts
  puts "When you've done that, come back and hit 'enter' so we can start coding."
  STDIN.gets.chomp
  puts
  return tasks
end

#choose_interventionObject

Give choice of possible interventions due to high negative emotions



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/checkin.rb', line 53

def choose_intervention
  puts
  puts "Okay, let's take a couple of breaths, then let's talk about our options."
  puts
  breathing_exercise
  puts
  puts "Now, let's talk about your options for right now, before you start your work."
  puts "-= You can CHANGE your situation, environment or reactions."
  puts "-= You can ACCEPT that this is how you'll be feeling while you're working."
  puts "-= Or you can choose to try and LET GO of this feeling before you start your work."
  puts
  puts "What do you want to do right now? Type 'change', 'accept' or 'let go', or anything else to skip this."
  return STDIN.gets.chomp.downcase
end

#close_checkinObject



125
126
127
128
129
130
131
# File 'lib/checkin.rb', line 125

def close_checkin()
  puts "Thanks for checking in with yourself!"
  puts "If you want to see a log of your checkins, open this file again with the argument 'log'."
  if @note != nil
    puts "And to check the note you left yourself just now or in previous checkins, open this file with the argument 'pull'."
  end
end

#describe_feeling(el) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/checkin.rb', line 34

def describe_feeling(el)
  puts "DESCRIBE how you're feeling. Which of these emotions would you say it falls under?"
  puts
  puts "anger -=- joy -=- sadness -=- hurt -=- fear"
  puts
  puts "Type 'more' for a list of more words to help you figure out what you're feeling and how we'll categorize it."
  return categorize_feeling(STDIN.gets.chomp, el)
end

#describe_feeling_instensityObject



43
44
45
46
47
48
49
50
# File 'lib/checkin.rb', line 43

def describe_feeling_instensity
  puts
  puts "How strong is that feeling on a scale of 0 to 10?"
  intensity = STDIN.gets.chomp.to_i
  return 0 if intensity < 0
  return 10 if intensity > 10
  return intensity
end

#describe_triggerObject



68
69
70
71
72
# File 'lib/checkin.rb', line 68

def describe_trigger
  puts
  puts "Think for a minute about what prompted or triggered this feeling. Think for a minute. Type a quick note to yourself about it to remind you later if you'd like, or press enter when ready."
  return STDIN.gets.chomp
end

#get_tasksObject

Read in list of tasks that the user wants to remember for later.



169
170
171
172
173
174
175
176
177
# File 'lib/checkin.rb', line 169

def get_tasks
  note_to_self = ""
  task = STDIN.gets.chomp
  until task.downcase == "done"
    note_to_self += " o " + task + "\n"
    task = STDIN.gets.chomp
  end
  return note_to_self.chomp
end

#let_go_selfObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/checkin.rb', line 110

def let_go_self
  puts "Think about this trigger and your emotions from it. Ask yourself:"
  puts "- Is it worth it?"
  puts "- Is this something I can leave or let go of and move on from this experience?"
  puts "- Can I learn from this experience?"
  puts "- What would I want to do differently next time?"
  puts
  puts "Jot a note to yourself about this. Hit enter when done."
  note_to_self = STDIN.gets.chomp
  puts
  puts "Now that you've logged how you're feeling and what might have caused it, think about how you don't have to hold onto that trigger anymore if you don't want to."
  puts
  return note_to_self
end

#observe_feelingObject



27
28
29
30
31
32
# File 'lib/checkin.rb', line 27

def observe_feeling
  puts
  puts "OBSERVE how you're feeling."
  puts "No need to judge it, let's just pause and notice it."
  pause_for(25)
end

#pause_for(seconds) ⇒ Object

used to add some mindful wait time so user can observe emotions



143
144
145
146
# File 'lib/checkin.rb', line 143

def pause_for(seconds)
  seconds.times { |s| print ((seconds - s).to_s + "... ") ; sleep 1 }
  puts
end

#to_hObject

Display checkin as a hash



180
181
182
183
184
185
186
187
188
189
# File 'lib/checkin.rb', line 180

def to_h
  return {
    time: @time,
    emotion: @emotional_state[:emotion],
    state: @emotional_state[:state],
    intensity: @intensity ||= nil,
    trigger: @trigger ||= nil,
    note: @note ||= nil
  }
end