#!/usr/bin/env ruby class LineType def initialize (strippedLine) @strippedLine = strippedLine end def isValid !(s[-1] != ";") end end class VariableLineType < LineType UNINITIALIZED_REGEX = /var[" "]([a-zA-Z0-9])\w+: [a-zA-Z]*([!]?[?]?)/ INITIALIZED_REGEX = /var[" "]([a-zA-Z0-9])\w+ = ([a-zA-Z0-9]?"?[(]?[)]?.?)*/ def isValid isValidUninitialized || isValidInitialized # super.isValid && (isValidUninitialized || isValidInitialized) end def isValidUninitialized !!(@strippedLine =~ UNINITIALIZED_REGEX) && !(@strippedLine.include? "=") end def isValidInitialized !!(@strippedLine =~ INITIALIZED_REGEX) end end class ConstantLineType < LineType UNINITIALIZED_REGEX = /let[" "]([a-zA-Z0-9])\w+: [a-zA-Z]*([!]?[?]?)/ INITIALIZED_REGEX = /let[" "]([a-zA-Z0-9])\w+ = ([a-zA-Z0-9]?"?[(]?[)]?.?)*/ def isValid isValidUninitialized || isValidInitialized # super.isValid && isValidUninitialized || isValidInitialized end def isValidUninitialized !!(@strippedLine =~ UNINITIALIZED_REGEX) && !(@strippedLine.include? "=") end def isValidInitialized !!(@strippedLine =~ INITIALIZED_REGEX) end end class ClassLineType < LineType CLASS_REGEX = /class[" "]([a-zA-Z])\w+((: (([a-zA-Z])\w+))((, (([a-zA-Z])\w+)){0,10}))? {/ def isValid !!(@strippedLine =~ CLASS_REGEX) end end class CommentLineType < LineType COMMENT_WITH_COMMENTS_REGEX = /\/\/\/?(( (?=.))(.{0,}))/ COMMENT_WITHOUT_COMMENTS_REGEX = /\/\/\/?(?!.)/ def isValid !!(@strippedLine =~ COMMENT_WITH_COMMENTS_REGEX) || !!(@strippedLine =~ COMMENT_WITHOUT_COMMENTS_REGEX) end end