-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreject.rb
executable file
·38 lines (25 loc) · 917 Bytes
/
reject.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env ruby
require './lib/initialize'
print "all odd numbers: "
p @numbers.reject(&:even?)
print "all negative numbers: "
p @numbers.reject{|number| number >= 0}
divider
print "all pets without legs: "
p @inventory.reject{|pet| pet.legs > 0}.map(&:name)
print "all pets out of stock: "
p @inventory.reject(&:in_stock?).map(&:name)
print "all pets without a name: "
p @inventory.reject{|pet| !pet.name.nil?}.map(&:name)
divider
print "pokey things without at least 5 letters: "
@pokey_things.seek(0)
p @pokey_things.reject{|line| line.chomp.size >= 5}.map(&:chomp)
print "pokey things without the letter 'e': "
@pokey_things.seek(0)
p @pokey_things.reject{|line| line.include?('e')}.map(&:chomp)
divider
print "all heroku requests NOT made via the GET method: "
p @requests.reject(&:get?).map(&:id)
print "all heroku requests NOT made via the POST method: "
p @requests.reject(&:post?).map(&:id)