Sha256: 35c1e71f55726ab2aae93c2bc66c1fa34c3bbfcb3226e803b61cae05c212c62c

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

class Array
  def arrivals
    self.select {|flights| flights.kind == 'Arrivals' }
  end

  def departure
    self.select {|flights| flights.kind == 'Departure' }
  end

  def yesterday
    self.select {|flights| flights.datetime.to_time >= Date.today.prev_day.to_time && flights.datetime.to_time <= Date.today.to_time }
  end

  def today
    self.select {|flights| flights.datetime.to_time >= Date.today.to_time && flights.datetime.to_time <= Date.today.next_day.to_time }
  end

  def tomorrow
    self.select {|flights| flights.datetime.to_time >= Date.today.next_day.to_time }
  end

  def by_datetime(datetime = DateTime.now)
    self.select {|flights| flights.datetime > datetime }
  end

  def filter_kind
    {
      Arrivals: self.select {|flights| flights.kind == 'Arrivals'},
      Departure: self.select {|flights| flights.kind == 'Departure'}
    }
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
hasami-0.1.1 lib/hasami/flight_helper.rb
hasami-0.1.0 lib/hasami/flight_helper.rb
Alohaha-0.0.6 lib/alohaha/flight_helper.rb