Sha256: 736e69789f072d12ae3766e046dce4bcb1eca1da6b783d0dcb44b696c2724e9d

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 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"
    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

2 entries across 2 versions & 1 rubygems

Version Path
dftsg-0.1.2 lib/LineDeterminator.rb
dftsg-0.1.1 lib/LineDeterminator.rb