helpers.coffee | |
---|---|
Define the base class for all commands. | class exports.Command
constructor: (@count = 1) ->
isRepeatable: yes |
If the class specifies a regex for char(s) that should follow the command, then the command isn't complete until those char(s) have been matched. | isComplete: ->
if @constructor.followedBy then @followedBy else true |
A bunch of commands can just repeat an action however many times their | exports.repeatCountTimes = (func) ->
(jim) ->
timesLeft = @count
func.call this, jim while timesLeft--
|