Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/compat/opal/rexml_compat.rb,
lib/compat/opal/rexml_compat.rb,
lib/compat/opal/rexml_compat.rb

Overview

Opal defines mutable String methods as raising NotImplementedError. Override with functional equivalents that return new strings.

Instance Method Summary collapse

Instance Method Details

#<<(str) ⇒ Object



39
40
41
# File 'lib/compat/opal/rexml_compat.rb', line 39

def <<(str)
  `return self + #{str}.to_s`
end

#chomp!(sep = nil) ⇒ Object



43
44
45
46
47
48
# File 'lib/compat/opal/rexml_compat.rb', line 43

def chomp!(sep = nil)
  `
    var r = #{chomp(sep)};
    return r === self ? nil : r;
  `
end

#encodeObject



30
31
32
# File 'lib/compat/opal/rexml_compat.rb', line 30

def encode(*)
  self
end

#force_encodingObject



15
16
17
# File 'lib/compat/opal/rexml_compat.rb', line 15

def force_encoding(*)
  self
end

#gsub!(pattern, replacement, &block) ⇒ Object



50
51
52
53
54
55
# File 'lib/compat/opal/rexml_compat.rb', line 50

def gsub!(pattern, replacement, &block)
  `
    var r = #{gsub(pattern, replacement, &block)};
    return r === self ? nil : r;
  `
end

#squeeze!(*sets) ⇒ Object



57
58
59
60
61
62
# File 'lib/compat/opal/rexml_compat.rb', line 57

def squeeze!(*sets)
  `
    var r = #{squeeze(*sets)};
    return r === self ? nil : r;
  `
end

#strip!Object



64
65
66
67
68
69
# File 'lib/compat/opal/rexml_compat.rb', line 64

def strip!
  `
    var r = #{strip};
    return r === self ? nil : r;
  `
end