opal/opal/builder/builder_mutable_string.rb
class BuilderMutableString
def initialize(str)
@state = str
end
def <<(text)
@state += text
self
end
def to_s
@state
end
def to_str
@state
end
def nil?
@state.nil?
end
# Unpack doesn't exist in Opal
def to_xs
gsub(/&(?!\w+;)/, '&')
.gsub(/</, '<')
.gsub(/>/, '>')
.gsub(/'/, ''')
end
def gsub(regex, replace)
@state = @state.gsub regex,replace
self
end
def ==(other_str)
@state == other_str
end
def size
@state.size
end
end