| Total Complexity | 12 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | # frozen_string_literal: true |
||
| 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.cancel_response |
||
| 26 | CANCEL_RESPONSE |
||
| 27 | end |
||
| 28 | |||
| 29 | def self.list_tests |
||
| 30 | format(LIST_TEST_RESPONSE, count: Instrument.count, list: Instrument.list_tests(limit: 4)) |
||
| 31 | end |
||
| 32 | |||
| 33 | def self.start_test(testname: AppConstants::DEFAULT_INSTRUMENT) |
||
| 34 | instrument = Instrument.find_by(name: testname) |
||
| 35 | return format(AlexaConstants::CANNOT_FIND_INSTRUMENT_ERROR, instrument: testname) unless instrument |
||
| 36 | instrument.instructions |
||
| 37 | end |
||
| 38 | |||
| 39 | def initialize(user) |
||
| 40 | @user = user |
||
| 41 | end |
||
| 42 | |||
| 43 | def read_all |
||
| 44 | user.journal.list_entries(limit: 4) |
||
| 45 | end |
||
| 46 | |||
| 47 | def read_entry(day: Date.today) |
||
| 48 | user.journal.read_entry(day: day) |
||
| 49 | end |
||
| 50 | |||
| 51 | def read_last(last_n: 1) |
||
| 52 | user.journal.read_last(last_n: last_n) |
||
| 53 | end |
||
| 54 | end |
||
| 55 |