Class: DropWhileDrill
- Inherits:
-
Drill
- Object
- Drill
- DropWhileDrill
show all
- Defined in:
- lib/ruby_drills/array/drop_while_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
19
20
21
|
# File 'lib/ruby_drills/array/drop_while_drill.rb', line 19
def reference
"@b.drop_while {|x| x < 4}"
end
|
#setup ⇒ Object
3
4
5
6
|
# File 'lib/ruby_drills/array/drop_while_drill.rb', line 3
def setup
@b = [1, 2, 3, 4, 5, 0]
@hints = ["http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-drop_while"]
end
|
#show ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/ruby_drills/array/drop_while_drill.rb', line 8
def show
puts %{
@b = #{@b.inspect}
Use the Enumerable method that removes elements up to, but not including,
the first element for which the block returns nil or false and returns an array
containing the remaining elements, resulting in:
#{expected}
}
end
|
#valid?(input) ⇒ Boolean
23
24
25
|
# File 'lib/ruby_drills/array/drop_while_drill.rb', line 23
def valid?(input)
input.include?('drop_while')
end
|