Sha256: 3c38a5a536ea0f2bfd1038c1716403035fc89a8a788c80dd5ba11553d1628398

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

Contents

#!/usr/bin/env ruby

class LineDeterminator
    def initialize (line)
        @strippedLine = line.strip
    end
    
    def isComment
        @strippedLine[0...2] == "//" or @strippedLine[0...3] == "///"
    end
    
    def isVar
        @strippedLine[0...3] == "var"
    end
    
    def isLet
        @strippedLine[0...3] == "let"
    end
    
    def isClass
        @strippedLine[0...5] == "class" and !(@strippedLine.include? "func")
    end
    
    def isFunction
        @strippedLine[0...4] == "func"
    end
    
    def lineType
        if isComment
            return CommentLineType.new(@strippedLine)
        end
        
        if isVar
            return VariableLineType.new(@strippedLine)
        end
        
        if isLet
            return ConstantLineType.new(@strippedLine)
        end
        
        if isClass
            return ClassLineType.new(@strippedLine)
        end
        
        return LineType.new(@strippedLine)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dftcc-0.1.0 lib/LineDeterminator.rb