Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/core_ext.rb
Instance Method Summary collapse
-
#after(time) ⇒ Object
Filters elements, collecting those whose times are after time.
-
#before(time) ⇒ Object
Filters elements, collecting those whose times are before time.
-
#in(time) ⇒ Object
The ‘in’ is just sugar really, saving the programmer from doing a trivial computation over and over again in their code.
Instance Method Details
#after(time) ⇒ Object
Filters elements, collecting those whose times are after time
13 14 15 16 |
# File 'lib/core_ext.rb', line 13 def after time query_time = Time.parse(time) select {|t| t.arrival[:expected] >= query_time } end |
#before(time) ⇒ Object
Filters elements, collecting those whose times are before time
6 7 8 9 |
# File 'lib/core_ext.rb', line 6 def before time query_time = Time.parse(time) select {|t| t.arrival[:expected] <= query_time } end |
#in(time) ⇒ Object
The ‘in’ is just sugar really, saving the programmer from doing a trivial computation over and over again in their code.
21 22 23 |
# File 'lib/core_ext.rb', line 21 def in time select { |t| t.due_in <= time } end |