4 * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
12 var Node = require('./node')
13 , nodes = require('./');
16 * Initialize a new `String` with the given `val`.
22 var String = module.exports = function String(val){
29 * Inherit from `Node.prototype`.
32 String.prototype.__proto__ = Node.prototype;
35 * Return quoted string.
41 String.prototype.toString = function(){
42 return '"' + this.val + '"';
46 * Return a clone of this node.
52 String.prototype.clone = function(){
53 var clone = new String(this.val);
54 clone.lineno = this.lineno;
59 * Return Boolean based on the length of this string.
65 String.prototype.toBoolean = function(){
66 return nodes.Boolean(this.val.length);
70 * Coerce `other` to a string.
77 String.prototype.coerce = function(other){
78 if (other instanceof String) {
81 return new String(other.toString());
86 * Operate on `right` with the given `op`.
94 String.prototype.operate = function(op, right){
97 return new String(this.val + right.val);
99 return Node.prototype.operate.call(this, op, right);