-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathselect.rb
executable file
·38 lines (25 loc) · 892 Bytes
/
select.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 even numbers: "
p @numbers.select(&:even?)
print "all positive numbers: "
p @numbers.select{|number| number >= 0}
divider
print "all pets with legs: "
p @inventory.select{|pet| pet.legs > 0}.map(&:name)
print "all pets in stock: "
p @inventory.select(&:in_stock?).map(&:name)
print "all pets with name: "
p @inventory.select{|pet| !pet.name.nil?}.map(&:name)
divider
print "pokey things with at least 5 letters: "
@pokey_things.seek(0)
p @pokey_things.select{|line| line.chomp.size >= 5}.map(&:chomp)
print "pokey things with the letter 'e': "
@pokey_things.seek(0)
p @pokey_things.select{|line| line.include?('e')}.map(&:chomp)
divider
print "all heroku requests made via the GET method: "
p @requests.select(&:get?).map(&:id)
print "all heroku requests made via the POST method: "
p @requests.select(&:post?).map(&:id)