Class: RailsAdmin::AbstractModel::StatementBuilder::FilteringDuration
- Inherits:
-
Object
- Object
- RailsAdmin::AbstractModel::StatementBuilder::FilteringDuration
- Defined in:
- lib/rails_admin/abstract_model.rb
Instance Method Summary collapse
- #between ⇒ Object
- #default ⇒ Object
- #get_duration ⇒ Object
-
#initialize(operator, value) ⇒ FilteringDuration
constructor
A new instance of FilteringDuration.
- #last_week ⇒ Object
- #this_week ⇒ Object
- #today ⇒ Object
- #yesterday ⇒ Object
Constructor Details
#initialize(operator, value) ⇒ FilteringDuration
Returns a new instance of FilteringDuration.
195 196 197 198 |
# File 'lib/rails_admin/abstract_model.rb', line 195 def initialize(operator, value) @value = value @operator = operator end |
Instance Method Details
#between ⇒ Object
228 229 230 |
# File 'lib/rails_admin/abstract_model.rb', line 228 def between [@value[1], @value[2]] end |
#default ⇒ Object
232 233 234 |
# File 'lib/rails_admin/abstract_model.rb', line 232 def default [default_date, default_date] end |
#get_duration ⇒ Object
200 201 202 203 204 205 206 207 208 209 |
# File 'lib/rails_admin/abstract_model.rb', line 200 def get_duration case @operator when 'between' then between when 'today' then today when 'yesterday' then yesterday when 'this_week' then this_week when 'last_week' then last_week else default end end |
#last_week ⇒ Object
223 224 225 226 |
# File 'lib/rails_admin/abstract_model.rb', line 223 def last_week [1.week.ago.to_date.beginning_of_week, 1.week.ago.to_date.end_of_week] end |
#this_week ⇒ Object
219 220 221 |
# File 'lib/rails_admin/abstract_model.rb', line 219 def this_week [Date.today.beginning_of_week, Date.today.end_of_week] end |
#today ⇒ Object
211 212 213 |
# File 'lib/rails_admin/abstract_model.rb', line 211 def today [Date.today, Date.today] end |
#yesterday ⇒ Object
215 216 217 |
# File 'lib/rails_admin/abstract_model.rb', line 215 def yesterday [Date.yesterday, Date.yesterday] end |