Class: PartitionDrill
- Inherits:
-
Drill
- Object
- Drill
- PartitionDrill
show all
- Defined in:
- lib/ruby_drills/array/partition_drill.rb,
lib/ruby_drills/string/partition_drill.rb
Constant Summary
Constants included
from Commands
Commands::GAMBLER
Instance Attribute Summary
Attributes inherited from Drill
#hints, #next, #previous
Instance Method Summary
collapse
Methods inherited from Drill
#done?, #drills, #expected, #initialize, #non!
Methods included from Commands
#back, #clear, #continue, #fail, #fold, #help, #hint, #quit, #review, #skip, #welcome, #win
Constructor Details
This class inherits a constructor from Drill
Instance Method Details
#reference ⇒ Object
20
21
22
|
# File 'lib/ruby_drills/array/partition_drill.rb', line 20
def reference
"@numbers.partition {|x| x.even? }"
end
|
#setup ⇒ Object
2
3
4
5
|
# File 'lib/ruby_drills/array/partition_drill.rb', line 2
def setup
@numbers = (0...10).to_a
@hints = ["What's another word for 'split' or 'divide'?", "http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-partition"]
end
|
#show ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/ruby_drills/array/partition_drill.rb', line 7
def show
puts %{
@numbers = #{@numbers.inspect}
Split this array into even and odd numbers to obtain
#{expected}.
Use the method that returns two arrays, the first containing
the elements of enum for which the block evaluates to true,
the second containing the rest.
}
end
|
#valid?(input) ⇒ Boolean
24
25
26
|
# File 'lib/ruby_drills/array/partition_drill.rb', line 24
def valid?(input)
input.include?('partition')
end
|