 ###
 
 class RuleMatcher
+    
+    #
+    # Setup the local variables
+    # @constructor
+    # 
     constructor: ()->
         @_binaryRule = ""
         @_patterns = [

            '000'
        ]

    setCurrentRule: (decimalRule)->
        # The binary rule contains the sequence of
        # 0's (no block) and 1's (block) for the
        # next row.
        @_binaryRule = @_decToBinary(decimalRule)

    getCurrentRule: ()->
        return @_binaryRule

    match: (zeroIndex,oneIndex,twoIndex)->
        # Match three cells within
        patternToFind = "#{zeroIndex}#{oneIndex}#{twoIndex}"


        # Return the binary rule's 0 or 1 mapping
        return parseInt(@_binaryRule.substr(foundPatternIndex,1))

    #
    # Convert a decimal value to its binary representation
    #
    # @return string Binary rule
    # 
    _decToBinary: (decValue)->
        # Generate the binary string from the decimal
        binary = (parseInt(decValue)).toString(2)
