Sha256: 2c0208a6af3fbbb9f31aa512fd825b6f72e10cb2e432bc964e55b4cdf265d347

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

class Utils

  @random_string: ->
    chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"
    ret = ""
    for i in [0..16]
      rnum = Math.floor(Math.random() * chars.length)
      ret += chars.substring(rnum,rnum+1)
    return ret

  @tokenize: (input) =>
    input = input.toLowerCase()
    input = input.replace(/\,/g, " , ")
    input = input.replace(/\./g, " . ")
    input = input.replace(/\n/g, "")
    input = input.replace(/\ \ /g, " ")
    return input

  @split_source: (text) ->
    delimiters = [".","!","?"]
    line = ""
    spliting = false
    firstSplit = false
    input = new Array()
    white = 0
    last = ' '
    for c in text
      #c = text[i]
      if (spliting == true)
          if (c != ' ' && c != '\n' && c != '\t')
            if (white > 0 || last == '\n')
              input[input.length] = line
              line = ""
            spliting = false
          else
            ++white
      line += c
      if (c == '.' || c == '!' || c == '?' || c == '\n')
        spliting = true
        white = 0
      last = c
    input[input.length] = line
    return input

  @trim: (text) =>
    return text.replace(/^\s+|\s+$/g, "")

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ajax-cat-1.0.0 lib/ajax-cat/public/Utils.coffee
ajax-cat-0.5.0 lib/ajax-cat/public/Utils.coffee
ajax-cat-0.4.2 lib/ajax-cat/public/Utils.coffee
ajax-cat-0.4.1 lib/ajax-cat/public/Utils.coffee
ajax-cat-0.4.0 lib/ajax-cat/public/Utils.coffee
ajax-cat-0.3.0 lib/ajax-cat/public/Utils.coffee
ajax-cat-0.2.0 lib/public/Utils.coffee