Class: CafeWellCLI

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

Instance Method Summary collapse

Instance Method Details

#activity_listObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cafe_well_cli.rb', line 7

def activity_list
  
  activity_form = current_page.form_with(:action => "/activity_entries/create_activity")
  select_list = activity_form.field_with(:name => "activity_entry[activity_id]")
  @activities = select_list.options.each_with_object(Hash.new) do |option, list|
    list[option.text] = option.value
  end
  puts "ID ------- Activity"
  puts "-------------------"
  @activities.each { |name, id| puts id + " -- " + name }
end

#add_activity(activity_id, minutes, date = today) ⇒ Object



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

def add_activity(activity_id, minutes, date = today)
  return "Invalid Date" unless valid?(date)
  
  activity_form = current_page.form_with(:action => "/activity_entries/create_activity") do |form|
    form.field_with(:name => "activity_entry[performed_at]").value = euro_date(date)
    form.field_with(:name => "activity_entry[activity_id]").value = activity_id
    form.field_with(:name => "activity_entry[activity_unit_value]").value = minutes
  end
  submit(activity_form, "Added activity.")
end

#add_break(date = today) ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'lib/cafe_well_cli.rb', line 79

def add_break(date = today)
  return "Invalid Date" unless valid?(date)
  
  break_form = current_page.form_with(:action => "/challenges/stress-break/post_progress") do |form|
    form.field_with(:name => "user_challenge_progress[activity_date]").value = euro_date(date)
    form.field_with(:name => "user_challenge_progress[reported_value]").value = 1
  end
  submit(break_form, "Added break.")
end

#add_meals(meal_count, date = today) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/cafe_well_cli.rb', line 57

def add_meals(meal_count, date = today)
  return "Invalid Date" unless valid?(date)
  
  meal_form = current_page.form_with(:action => "/challenges/food-swap-challenge/post_progress") do |form|
    form.field_with(:name => "user_challenge_progress[activity_date]").value = euro_date(date)
    form.field_with(:name => "user_challenge_progress[reported_value]").value = meal_count
  end
  submit(meal_form, "Added meals.")
end

#add_sleep(date = today) ⇒ Object



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

def add_sleep(date = today)
  return "Invalid Date" unless valid?(date)
  
  sleep_form = current_page.form_with(:action => "/challenges/rest-and-reset/post_progress") do |form|
    form.field_with(:name => "user_challenge_progress[activity_date]").value = euro_date(date)
    form.field_with(:name => "user_challenge_progress[reported_value]").value = 1
  end
  submit(sleep_form, "Added sleep.")
end

#infoObject



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/cafe_well_cli.rb', line 135

def info
  puts <<-INFO
    Move To Improve:
      Earn up to $300
      For every minute of exercise, you earn a point
      First 2,000 points = $25
      Each 1,000 points after is another $25

    Healthy Eating:  Food Swap Challenge (ends 6/30/2014)
      Earn up to $300
      Enter how many healthy meals you ate that day (max 6)
      Every healthy meal earns a point
      First 130 points = $25
      Each 60 points after is another $25

    Rest and Reset:  (ends 12/31/2014)
      Earn up to $150
      Report each night you've gotten at least 7 hours of sleep.

    Stress Break: (ends 4/30/2014)
      Earn up to $150
      Report one stress break every day you take a 10 minute break
      Only receive credit for one break per day

    Family Activity: 5210 Campaign (ends 6/30/2014)
      Earn up to $100
      Daily Goal:
        5 or more fruits or vegetables
        2 hours or fewer screen time after work/school
        1 hour or more exercise
        0 sugary drinks
      Report one successful Campaign Day when the majority of
      your family members meet this goal
  INFO
end

#met_family_goal(date = today) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/cafe_well_cli.rb', line 101

def met_family_goal(date = today)
  return "Invalid Date" unless valid?(date)
  
  family_goal_form = current_page.form_with(:action => "/challenges/5210-campaign/post_progress") do |form|
    form.field_with(:name => "user_challenge_progress[activity_date]").value = euro_date(date)
    form.field_with(:name => "user_challenge_progress[reported_value]").value = 2
  end
  submit(family_goal_form, "Added family goal day.")
end