   #   @option endPos [Integer] pos position in last word of selection
   #   @option options [Object] style the style of the selection
   constructor: (a, b, c, d, e)->
-    if a? and b? and c? and d?
-      if !( typeof a is "number" and
-            typeof b is "number" and
-            typeof c is "number" and
-            typeof d is "number")
+    if not _.isUndefined(a) and not _.isUndefined(b) and not _.isUndefined(c) and not _.isUndefined(d)
+      if !( _.isNumber(a) and
+            _.isNumber(b) and
+            _.isNumber(c) and
+            _.isNumber(d))
         throw new Error "Expecting numbers as arguments"
       @startPos = {word: a, pos: b}
       @endPos = {word: c, pos: d}
 
       style = e
 
-    else if a? and b? and c?
-      if !( typeof a is "number" and
-            typeof b is "number")
+    else if not _.isUndefined(a) and not _.isUndefined(b) and not _.isUndefined(c)
+      if !( _.isNumber(a) and
+            _.isNumber(b))
         throw new Error "Expecting numbers as arguments"
       c.constructor is "Rte"
 
       [@startPos, @endPos] = @_relativeFromAbsolute(a, b, c)
       attr = d
 
-    else if a? and b? and a.pos? and a.word? and b.pos? and b.word?
+    else if not _.isUndefined(a) and not _.isUndefined(b) and a.pos? and a.word? and b.pos? and b.word?
       @startPos = a
       @endPos = b
 

  # @param [String] content the content to insert
  #
  insert: (sel, content)->
    if not sel.startPos?
      throw new Error "Expected a location object as first argument"
    if typeof content isnt "string"
      throw new Error "Expected a string as second argument"

    n = sel.startPos.word
    pos = sel.startPos.pos
    word = @getWord(n)
    @setWord(n, word.substring(0, pos) + content + word.substring(pos))

  # Relative jump from position
  #

_ = require 'underscore'

splitWord = word ->
  word.match(/(^ +|)\W+ +/g)


buildWord = (word, prepend='', append='') ->
  tmp = word.match /(^ +|)\W+ +/g
  tmp2 = []

  if tmp.length == 1
