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.
226 227 228 229 |
# File 'lib/rails_admin/abstract_model.rb', line 226 def initialize(operator, value) @value = value @operator = operator end |
Instance Method Details
#between ⇒ Object
259 260 261 |
# File 'lib/rails_admin/abstract_model.rb', line 259 def between [@value[1], @value[2]] end |
#default ⇒ Object
263 264 265 |
# File 'lib/rails_admin/abstract_model.rb', line 263 def default [default_date, default_date] end |
#get_duration ⇒ Object
231 232 233 234 235 236 237 238 239 240 |
# File 'lib/rails_admin/abstract_model.rb', line 231 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
254 255 256 257 |
# File 'lib/rails_admin/abstract_model.rb', line 254 def last_week [1.week.ago.to_date.beginning_of_week, 1.week.ago.to_date.end_of_week] end |
#this_week ⇒ Object
250 251 252 |
# File 'lib/rails_admin/abstract_model.rb', line 250 def this_week [Date.today.beginning_of_week, Date.today.end_of_week] end |
#today ⇒ Object
242 243 244 |
# File 'lib/rails_admin/abstract_model.rb', line 242 def today [Date.today, Date.today] end |
#yesterday ⇒ Object
246 247 248 |
# File 'lib/rails_admin/abstract_model.rb', line 246 def yesterday [Date.yesterday, Date.yesterday] end |