You're an avid bird watcher that keeps track of how many birds have visited your garden in the last seven days.
You have five tasks, all dealing with the numbers of birds that visited your garden.
For comparison purposes, you always keep a copy of last week's counts nearby, which were: 0, 2, 5, 3, 7, 8 and 4. Implement the BirdCount.last_week method that returns last week's counts:
BirdCount.last_week
# => [0, 2, 5, 3, 7, 8, 4]Implement the BirdCount#yesterday method to return how many birds visited your garden yesterday. The bird counts are ordered by day, with the first element being the count of the oldest day, and the last element being today's count.
birds_per_day = [2, 5, 0, 7, 4, 1]
bird_count = BirdCount.new(birds_per_day)
bird_count.yesterday
# => 4Implement the BirdCount#total method to return the total number of birds that have visited your garden:
birds_per_day = [2, 5, 0, 7, 4, 1]
bird_count = BirdCount.new(birds_per_day)
bird_count.total
# => 19Some days are busier than others. A busy day is one where five or more birds have visited your garden.
Implement the BirdCount#busy_days method to return the number of busy days:
birds_per_day = [2, 5, 0, 7, 4, 1]
bird_count = BirdCount.new(birds_per_day)
bird_count.busy_days
# => 2Implement the BirdCount#day_without_birds? method that returns true if there was a day at which zero birds visited the garden; otherwise, return false:
birds_per_day = [2, 5, 0, 7, 4, 1]
bird_count = BirdCount.new(birds_per_day)
bird_count.day_without_birds?
# => trueYou're an avid bird watcher that keeps track of how many birds have visited your garden in the last seven days.
You have five tasks, all dealing with the numbers of birds that visited your garden.
For comparison purposes, you always keep a copy of last week's counts nearby, which were: 0, 2, 5, 3, 7, 8 and 4. Implement the BirdCount.last_week method that returns last week's counts:
BirdCount.last_week
# => [0, 2, 5, 3, 7, 8, 4]Implement the BirdCount#yesterday method to return how many birds visited your garden yesterday. The bird counts are ordered by day, with the first element being the count of the oldest day, and the last element being today's count.
birds_per_day = [2, 5, 0, 7, 4, 1]
bird_count = BirdCount.new(birds_per_day)
bird_count.yesterday
# => 4Implement the BirdCount#total method to return the total number of birds that have visited your garden:
birds_per_day = [2, 5, 0, 7, 4, 1]
bird_count = BirdCount.new(birds_per_day)
bird_count.total
# => 19Some days are busier than others. A busy day is one where five or more birds have visited your garden.
Implement the BirdCount#busy_days method to return the number of busy days:
birds_per_day = [2, 5, 0, 7, 4, 1]
bird_count = BirdCount.new(birds_per_day)
bird_count.busy_days
# => 2Implement the BirdCount#day_without_birds? method that returns true if there was a day at which zero birds visited the garden; otherwise, return false:
birds_per_day = [2, 5, 0, 7, 4, 1]
bird_count = BirdCount.new(birds_per_day)
bird_count.day_without_birds?
# => true