Module: Dialog
- Defined in:
- lib/dialog.rb
Constant Summary collapse
- TRANSLATION =
{ task: 'задача', subtask: 'подзадача', note: 'заметка', created: 'создана', finished: 'завершена' }
- WEEK =
[nil, 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']
Instance Attribute Summary collapse
-
#new_note_text ⇒ Object
readonly
Returns the value of attribute new_note_text.
-
#new_subtask_title ⇒ Object
readonly
Returns the value of attribute new_subtask_title.
-
#new_task_description ⇒ Object
readonly
Returns the value of attribute new_task_description.
-
#new_task_title ⇒ Object
readonly
Returns the value of attribute new_task_title.
Class Method Summary collapse
- .ask_new_note ⇒ Object
- .ask_new_subtask ⇒ Object
- .ask_new_task ⇒ Object
- .say_report(report) ⇒ Object
- .say_task(task: task, subtasks: subtasks, notes: notes) ⇒ Object
- .say_tasks(tasks, indentation = '') ⇒ Object
Instance Attribute Details
#new_note_text ⇒ Object (readonly)
Returns the value of attribute new_note_text.
6 7 8 |
# File 'lib/dialog.rb', line 6 def new_note_text @new_note_text end |
#new_subtask_title ⇒ Object (readonly)
Returns the value of attribute new_subtask_title.
6 7 8 |
# File 'lib/dialog.rb', line 6 def new_subtask_title @new_subtask_title end |
#new_task_description ⇒ Object (readonly)
Returns the value of attribute new_task_description.
6 7 8 |
# File 'lib/dialog.rb', line 6 def new_task_description @new_task_description end |
#new_task_title ⇒ Object (readonly)
Returns the value of attribute new_task_title.
6 7 8 |
# File 'lib/dialog.rb', line 6 def new_task_title @new_task_title end |
Class Method Details
.ask_new_note ⇒ Object
27 28 29 |
# File 'lib/dialog.rb', line 27 def self.ask_new_note @new_note_text = ask('Введите текст заметки: ') end |
.ask_new_subtask ⇒ Object
23 24 25 |
# File 'lib/dialog.rb', line 23 def self.ask_new_subtask @new_subtask_title = ask('Введите подзадачу: ') end |
.ask_new_task ⇒ Object
18 19 20 21 |
# File 'lib/dialog.rb', line 18 def self.ask_new_task @new_task_title = ask('Введите имя задачи: ') @new_task_description = ask('Введите описание задачи: ') end |
.say_report(report) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/dialog.rb', line 59 def self.say_report(report) say('Проведена работа по следующим задачам:') self.say_tasks(report[:tasks], ' ') say('=' * 27) report[:tasks].each do |task| say(task[:title] + ':') separator = false report[:events].select{ |event| event[:task_id] == task[:id] }.each do |event| say("\n") if separator separator = true wd = WEEK[ts_to_date(event[:timestamp], "%u").to_i] say(' ' + ts_to_date(event[:timestamp], "%Y-%m-%d (#{wd}) %H:%M:%S")) status = Unicode::capitalize(TRANSLATION[event[:status]]) object = TRANSLATION[event[:object]] text = "\"#{event[:text]}\"" say(" #{status} #{object} #{text}") end say('-' * 27) end end |
.say_task(task: task, subtasks: subtasks, notes: notes) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dialog.rb', line 40 def self.say_task(task: task, subtasks: subtasks, notes: notes) say("##{task[:id]} \"#{task[:title]}\"") say(ts_to_date(task[:created_at])) say(task[:description]) if subtasks[0] say('Подзадачи:') subtasks.each do |subtask| created_at = ts_to_date(subtask[:created_at]) say(" #{created_at} #{subtask[:title]} (##{subtask[:id]})") end end if notes[0] notes.each do |note| say("\n#{ts_to_date(note[:created_at])}") say(note[:text]) end end end |
.say_tasks(tasks, indentation = '') ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/dialog.rb', line 31 def self.say_tasks(tasks, indentation = '') tasks.each do |task| id = spaces("##{task[:id]}", 8) title = spaces(task[:title], 41) created_at = ts_to_date(task[:created_at]) say("#{indentation}#{id}#{title}#{created_at}") end end |