Class: Timekit::Filtercollection
- Inherits:
-
Object
- Object
- Timekit::Filtercollection
- Defined in:
- lib/timekit/filtercollection.rb
Constant Summary collapse
- DAYS =
%w( Monday Tuesday Wednesday Thursday Friday Saturday Sunday ).freeze
Instance Method Summary collapse
- #after_take_first(num) ⇒ Object
- #after_take_last(num) ⇒ Object
- #after_take_random(num) ⇒ Object
- #and_not_on_weekends(timezone = nil) ⇒ Object
- #and_on_day(day) ⇒ Object
- #and_only_during_business_hours(timezone = nil) ⇒ Object
- #as_json ⇒ Object
-
#initialize ⇒ Filtercollection
constructor
A new instance of Filtercollection.
- #or_between_times(timestamp1, timestamp2) ⇒ Object
- #or_on_any_days(days) ⇒ Object
Constructor Details
#initialize ⇒ Filtercollection
Returns a new instance of Filtercollection.
14 15 16 17 18 |
# File 'lib/timekit/filtercollection.rb', line 14 def initialize @and_conditions = [] @or_conditions = [] @after_conditions = [] end |
Instance Method Details
#after_take_first(num) ⇒ Object
32 33 34 |
# File 'lib/timekit/filtercollection.rb', line 32 def after_take_first(num) @after_conditions << { take_first: { number: num } } end |
#after_take_last(num) ⇒ Object
36 37 38 |
# File 'lib/timekit/filtercollection.rb', line 36 def after_take_last(num) @after_conditions << { take_last: { number: num } } end |
#after_take_random(num) ⇒ Object
28 29 30 |
# File 'lib/timekit/filtercollection.rb', line 28 def after_take_random(num) @after_conditions << { take_random: { number: num } } end |
#and_not_on_weekends(timezone = nil) ⇒ Object
44 45 46 |
# File 'lib/timekit/filtercollection.rb', line 44 def and_not_on_weekends(timezone = nil) @and_conditions << { exclude_weekends: timezone_param(timezone) } end |
#and_on_day(day) ⇒ Object
48 49 50 |
# File 'lib/timekit/filtercollection.rb', line 48 def and_on_day(day) @and_conditions << specific_day(day) end |
#and_only_during_business_hours(timezone = nil) ⇒ Object
40 41 42 |
# File 'lib/timekit/filtercollection.rb', line 40 def and_only_during_business_hours(timezone = nil) @and_conditions << { business_hours: timezone_param(timezone) } end |
#as_json ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/timekit/filtercollection.rb', line 20 def as_json { or: @or_conditions, and: @and_conditions, after: @after_conditions } end |
#or_between_times(timestamp1, timestamp2) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/timekit/filtercollection.rb', line 56 def or_between_times(, ) @or_conditions << { between_timestamps: { start: , end: } } end |
#or_on_any_days(days) ⇒ Object
52 53 54 |
# File 'lib/timekit/filtercollection.rb', line 52 def or_on_any_days(days) days.each { |day| @or_conditions << specific_day(day) } end |