Class: ReduceDrill
- Inherits:
-
Drill
show all
- Defined in:
- lib/ruby_drills/array/reduce_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
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
16
17
18
|
# File 'lib/ruby_drills/array/reduce_drill.rb', line 16
def reference
"@values.reduce(:+)/@values.size"
end
|
#setup ⇒ Object
3
4
5
6
|
# File 'lib/ruby_drills/array/reduce_drill.rb', line 3
def setup
@values = [ 1, 2, 3 ]
@hints = ["Use a method from the Enumerable module", "How could you use reduce to solve this problem?"]
end
|
#show ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/ruby_drills/array/reduce_drill.rb', line 8
def show
puts %{
@values = #{@values.inspect}
Calculate the mean of this array.
}
end
|
#valid?(input) ⇒ Boolean
20
21
22
|
# File 'lib/ruby_drills/array/reduce_drill.rb', line 20
def valid?(input)
input.include?("reduce")
end
|