Class: Drill
Direct Known Subclasses
AllDrill, AllNamesDrill, ChunkDrill, DropWhileDrill, PartitionDrill, ReduceDrill, TakeWhileDrill, ZipDrill
Constant Summary
Constants included from Commands
Instance Attribute Summary collapse
-
#hints ⇒ Object
Returns the value of attribute hints.
-
#next ⇒ Object
Returns the value of attribute next.
-
#previous ⇒ Object
Returns the value of attribute previous.
Instance Method Summary collapse
- #done?(input) ⇒ Boolean
- #drills ⇒ Object
- #expected ⇒ Object
-
#initialize ⇒ Drill
constructor
A new instance of Drill.
Methods included from Commands
#back, #clear, #continue, #fail, #fold, #help, #hint, #quit, #review, #skip, #welcome, #win
Constructor Details
#initialize ⇒ Drill
Returns a new instance of Drill.
5 6 7 8 |
# File 'lib/ruby_drills/drill.rb', line 5 def initialize setup @context = Pry.binding_for(self) end |
Instance Attribute Details
#hints ⇒ Object
Returns the value of attribute hints.
3 4 5 |
# File 'lib/ruby_drills/drill.rb', line 3 def hints @hints end |
#next ⇒ Object
Returns the value of attribute next.
3 4 5 |
# File 'lib/ruby_drills/drill.rb', line 3 def next @next end |
#previous ⇒ Object
Returns the value of attribute previous.
3 4 5 |
# File 'lib/ruby_drills/drill.rb', line 3 def previous @previous end |
Instance Method Details
#done?(input) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby_drills/drill.rb', line 19 def done?(input) case input.to_sym when :menu RubyDrills::Config::SESSIONS.command(self.class.name, input) clear true when :exit RubyDrills::Config::SESSIONS.command(self.class.name, input) quit when :show RubyDrills::Config::SESSIONS.command(self.class.name, input) show when lambda {|s| Commands.instance_methods.include?(s) } RubyDrills::Config::SESSIONS.command(self.class.name, input) self.send(input) else check_answer(input) end end |
#drills ⇒ Object
10 11 12 13 |
# File 'lib/ruby_drills/drill.rb', line 10 def drills # Composite pattern: Allow for drill.start to work in the REPL or in tests. [self] end |
#expected ⇒ Object
15 16 17 |
# File 'lib/ruby_drills/drill.rb', line 15 def expected eval(reference) end |