Class: Avmtrf1::Tools::Runner::Forponto::Resumos
- Inherits:
-
Object
- Object
- Avmtrf1::Tools::Runner::Forponto::Resumos
- Defined in:
- lib/avmtrf1/tools/runner/forponto/resumos.rb
Instance Method Summary collapse
- #head_month ⇒ Object
- #minutes_to_s(minutes) ⇒ Object
- #run ⇒ Object
- #show_month(month) ⇒ Object
- #show_month_acum_summaries(month) ⇒ Object
- #show_month_self_summaries(month) ⇒ Object
- #show_month_summaries(month) ⇒ Object
- #show_self_summaries(month) ⇒ Object
- #sorted_months_uncached ⇒ Object
- #summary_to_label(summary) ⇒ Object
- #summary_to_value(summary) ⇒ Object
Instance Method Details
#head_month ⇒ Object
20 21 22 23 24 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 20 def head_month today = ::Date.today # rubocop:disable Rails/Date date = ::Date.civil(today.year, today.month, 1) runner_context.call(:user).month(date.year, date.month) end |
#minutes_to_s(minutes) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 64 def minutes_to_s(minutes) signal = '' if minutes.negative? signal = '-' minutes = -minutes end time = [minutes / 60, minutes % 60].map { |x| x.to_s.rjust(2, '0') }.join(':') "#{signal}#{time} / #{signal}#{minutes} minutes" end |
#run ⇒ Object
14 15 16 17 18 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 14 def run sorted_months.each do |month| show_month(month) end end |
#show_month(month) ⇒ Object
26 27 28 29 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 26 def show_month(month) infov 'Month', month show_self_summaries(month) end |
#show_month_acum_summaries(month) ⇒ Object
50 51 52 53 54 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 50 def show_month_acum_summaries(month) infov ' * Débito acum.', minutes_to_s(month.debito_acum) infov ' * Crédito acum.', minutes_to_s(month.credito_acum) infov ' * Saldo acum.', minutes_to_s(month.saldo_acum) end |
#show_month_self_summaries(month) ⇒ Object
44 45 46 47 48 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 44 def show_month_self_summaries(month) infov ' * Débito', minutes_to_s(month.debito) infov ' * Crédito', minutes_to_s(month.credito) infov ' * Saldo', minutes_to_s(month.saldo) end |
#show_month_summaries(month) ⇒ Object
38 39 40 41 42 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 38 def show_month_summaries(month) month.os_data.summaries.each do |s| infov ' * ' + summary_to_label(s), summary_to_value(s) # rubocop:disable Style/StringConcatenation end end |
#show_self_summaries(month) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 31 def show_self_summaries(month) infov ' * Self summaries', month.os_data.summaries.count show_month_summaries(month) show_month_self_summaries(month) show_month_acum_summaries(month) end |
#sorted_months_uncached ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 74 def sorted_months_uncached r = [] current = head_month while current.present? r << current current = current.parent_month end r.reverse end |
#summary_to_label(summary) ⇒ Object
56 57 58 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 56 def summary_to_label(summary) "#{summary.code} - #{summary.description}" end |
#summary_to_value(summary) ⇒ Object
60 61 62 |
# File 'lib/avmtrf1/tools/runner/forponto/resumos.rb', line 60 def summary_to_value(summary) minutes_to_s(summary.minutes) end |