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
11 12 13 14 |
# File 'lib/core_ext.rb', line 11 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
4 5 6 7 |
# File 'lib/core_ext.rb', line 4 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.
19 20 21 |
# File 'lib/core_ext.rb', line 19 def in time select { |t| t.due_in <= time } end |