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



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

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

#chomp!(sep = nil) ⇒ Object



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

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

#encodeObject



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

def encode(*)
  self
end

#force_encodingObject



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

def force_encoding(*)
  self
end

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



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

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

#squeeze!(*sets) ⇒ Object



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

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

#strip!Object



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

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