Class: ReportMe::Report
- Inherits:
-
Object
- Object
- ReportMe::Report
- Defined in:
- lib/report_me/report.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ Report
constructor
A new instance of Report.
- #source(&block) ⇒ Object
- #sql(von, bis) ⇒ Object
- #table_exist?(period) ⇒ Boolean
- #table_name(period) ⇒ Object
Constructor Details
#initialize(name) ⇒ Report
Returns a new instance of Report.
8 9 10 |
# File 'lib/report_me/report.rb', line 8 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/report_me/report.rb', line 6 def name @name end |
Instance Method Details
#source(&block) ⇒ Object
12 13 14 |
# File 'lib/report_me/report.rb', line 12 def source(&block) @source = block end |
#sql(von, bis) ⇒ Object
16 17 18 |
# File 'lib/report_me/report.rb', line 16 def sql(von, bis) @source.call(von, bis) end |
#table_exist?(period) ⇒ Boolean
24 25 26 |
# File 'lib/report_me/report.rb', line 24 def table_exist?(period) ActiveRecord::Base.connection.select_value("show tables like '#{table_name(period)}'") != nil end |
#table_name(period) ⇒ Object
20 21 22 |
# File 'lib/report_me/report.rb', line 20 def table_name(period) "#{name}_#{period}" end |