Class: Fuso::Views::ReportView

Inherits:
Object
  • Object
show all
Defined in:
lib/fuso/views/report_view.rb

Instance Method Summary collapse

Instance Method Details

#export_csv(app) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/fuso/views/report_view.rb', line 45

def export_csv(app)
  if app.report_mode == :weekly
    export_weekly_csv(app)
  else
    export_monthly_csv(app)
  end
end

#render(app) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fuso/views/report_view.rb', line 10

def render(app)
  lines = []

  lines << ""
  lines << Styles.title.render("Fuso — Reports")
  lines << ""

  # Tab bar
  tabs = render_tabs(app)
  lines << "  #{tabs}"
  lines << ""

  # Navigation
  date_label = if app.report_mode == :weekly
                 monday = app.report_date - ((app.report_date.wday + 6) % 7)
                 sunday = monday + 6
                 "Week #{app.report_date.cweek}: #{monday.strftime('%b %d')}#{sunday.strftime('%b %d, %Y')}"
               else
                 app.report_date.strftime("%B %Y")
               end
  lines << "  " + Styles.dim.render("") + Styles.active_label.render(date_label) + Styles.dim.render("")
  lines << ""

  if app.report_mode == :weekly
    lines << render_weekly(app)
  else
    lines << render_monthly(app)
  end

  lines << ""
  lines << render_help

  lines.join("\n")
end