Module: Metior::Report::ViewHelper
- Included in:
- View
- Defined in:
- lib/metior/report/view_helper.rb
Overview
This helper module implements generic functionality that is included in all report views
Instance Method Summary collapse
-
#count ⇒ Fixnum
Increases the counter by one and returns it.
-
#even_odd ⇒ 'even', 'odd'
Returns whether the current counter value is even or odd.
-
#reset_count ⇒ Object
Resets the current counter to 0.
Instance Method Details
#count ⇒ Fixnum
Increases the counter by one and returns it
This can, for example, be used to count the values in an array that is iterated in a view.
21 22 23 24 |
# File 'lib/metior/report/view_helper.rb', line 21 def count @count ||= 0 @count += 1 end |
#even_odd ⇒ 'even', 'odd'
Returns whether the current counter value is even or odd
This is specifically useful for e.g. generating alternating colors of table rows in the output of the view.
34 35 36 |
# File 'lib/metior/report/view_helper.rb', line 34 def even_odd (count % 2 == 0) ? 'even' : 'odd' end |
#reset_count ⇒ Object
Resets the current counter to 0
41 42 43 |
# File 'lib/metior/report/view_helper.rb', line 41 def reset_count @count = 0 end |