Test Setup Failed
Push — master ( a4b3ec...9d5e67 )
by Steven
01:42
created

AlexaService.goodbye_response()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
# frozen_string_literal: true
2
3
# Class to define Alexa's intent behavior
4
class AlexaService
5
  include AlexaConstants
6
7
  attr_reader :user
8
9
  def self.goodbye_response
10
    GOODBYE_RESPONSE
11
  end
12
  
13
  def self.help_response
14
    HELP_RESPONSE
15
  end
16
17
  def self.launch_response
18
    LAUNCH_RESPONSE
19
  end
20
  
21
  def self.start_over_response
22
    START_OVER_RESPONSE
23
  end
24
25
  def self.list_tests
26
    format(LIST_TEST_RESPONSE, count: Instrument.count, list: Instrument.list_tests(limit: 4))
27
  end
28
29
  def self.start_test(testname: AppConstants::DEFAULT_INSTRUMENT)
30
    instrument = Instrument.find_by(name: testname)
31
    return format(AlexaConstants::CANNOT_FIND_INSTRUMENT_ERROR, instrument: testname) unless instrument
32
    instrument.instructions
33
  end
34
35
  def initialize(user)
36
    @user = user
37
  end
38
39
  def read_all
40
    user.journal.list_entries(limit: 4)
41
  end
42
43
  def read_entry(day: Date.today)
44
    user.journal.read_entry(day: day)
45
  end
46
47
  def read_last(last_n: 1)
48
    user.journal.read_last(last_n)
49
  end
50
end
51