Class: WoopleTheme::Reports::ActivityReportPresenter

Inherits:
ExplicitDelegator show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
app/presenters/woople_theme/reports/activity_report_presenter.rb

Constant Summary collapse

DAILY_LEGEND =
['0-3', '4-6', '7+']
WEEKLY_LEGEND =
['0-28', '29-48', '49+']
MONTHLY_LEGEND =
['0-123', '124-216', '217+']

Instance Method Summary collapse

Methods inherited from ExplicitDelegator

enforce_definitions, #enforced_methods, #ensure_defined, #initialize

Constructor Details

This class inherits a constructor from ExplicitDelegator

Instance Method Details

#chart_titleObject



52
53
54
55
56
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 52

def chart_title
  return I18n.t('woople_theme.reports.chart.titles.daily') if daily?
  return I18n.t('woople_theme.reports.chart.titles.weekly') if weekly?
  return I18n.t('woople_theme.reports.chart.titles.monthly') if monthly?
end

#containerObject



42
43
44
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 42

def container
  "#{tab_name}_report_chart"
end

#daily?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 58

def daily?
  report.type.to_s == 'week'
end

#hrefObject



38
39
40
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 38

def href
  "##{tab_name}"
end

#legendObject



46
47
48
49
50
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 46

def legend
  return DAILY_LEGEND if daily?
  return WEEKLY_LEGEND if weekly?
  return MONTHLY_LEGEND if monthly?
end

#monthly?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 66

def monthly?
  report.type.to_s == 'annual'
end

#nameObject



30
31
32
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 30

def name
  report.name.titleize
end


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 15

def report_link
  link_to(
    name,
    href,
    {
      data: {
        toggle: 'tab',
        type: type,
        container: container,
        path: data_path
      }
    }
  )
end

#tab_nameObject



34
35
36
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 34

def tab_name
  report.type.downcase
end

#weekly?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/presenters/woople_theme/reports/activity_report_presenter.rb', line 62

def weekly?
  report.type.to_s == 'month'
end