Class: SelfML::AST::StringNode

Inherits:
String
  • Object
show all
Defined in:
lib/selfml/ast/string_node.rb

Overview

SelfML::AST::StringNode

Instance Method Summary collapse

Instance Method Details

#<=>(rhs) ⇒ Object

Orders nodes correctly


17
18
19
20
21
# File 'lib/selfml/ast/string_node.rb', line 17

def <=> rhs
  case rhs when StringNode then  0
           when Node       then -1
                           else  1 end
end

#serializeString Also known as: to_s

Returns representation in string format

Returns:

  • (String)

    representation in string format


8
9
10
11
12
13
# File 'lib/selfml/ast/string_node.rb', line 8

def serialize
  return "`#{self.gsub("`","``")}`" if self.count("[") != self.count("]")
  return "[#{self}]"                if self.match(/[#`()\[\]{} ]/)
  
  self
end