Class: StatBoard::Reports::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/stat_board/reports/report.rb

Direct Known Subclasses

MonthlyReport, OverallReport, WeeklyReport

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_date, end_date) ⇒ Report

Returns a new instance of Report.



6
7
8
9
# File 'lib/stat_board/reports/report.rb', line 6

def initialize(start_date, end_date)
  @start_date = start_date
  @end_date = end_date
end

Instance Attribute Details

#end_dateObject (readonly)

Returns the value of attribute end_date.



4
5
6
# File 'lib/stat_board/reports/report.rb', line 4

def end_date
  @end_date
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



4
5
6
# File 'lib/stat_board/reports/report.rb', line 4

def start_date
  @start_date
end

Instance Method Details

#count(model) ⇒ Object



27
28
29
# File 'lib/stat_board/reports/report.rb', line 27

def count(model)
  scope(model).count
end

#nameObject



11
12
13
# File 'lib/stat_board/reports/report.rb', line 11

def name
  # define in subclass
end

#scope(model) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/stat_board/reports/report.rb', line 15

def scope(model)
  if model.is_a?(String)
    model.constantize
  else
    model
  end
end

#slugObject



23
24
25
# File 'lib/stat_board/reports/report.rb', line 23

def slug
  name.downcase.gsub(" ", "-")
end