Class: String

Inherits:
Object show all
Defined in:
opal/stdlib/json.rb,
opal/stdlib/native.rb,
opal/stdlib/encoding.rb

Instance Method Summary collapse

Instance Method Details

#bytesObject



131
132
133
# File 'opal/stdlib/encoding.rb', line 131

def bytes
  each_byte.to_a
end

#bytesizeObject



135
136
137
# File 'opal/stdlib/encoding.rb', line 135

def bytesize
  @encoding.bytesize(self)
end

#each_byte(&block) ⇒ Object



139
140
141
142
143
144
145
# File 'opal/stdlib/encoding.rb', line 139

def each_byte(&block)
  return enum_for :each_byte unless block_given?

  @encoding.each_byte(self, &block)

  self
end

#encodingObject



147
148
149
# File 'opal/stdlib/encoding.rb', line 147

def encoding
  @encoding
end

#force_encoding(encoding) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
# File 'opal/stdlib/encoding.rb', line 151

def force_encoding(encoding)
  encoding = Encoding.find(encoding)

  return self if encoding == @encoding

  %x{
    var result = new String(self);
    result.encoding = encoding;

    return result;
  }
end

#getbyte(idx) ⇒ Object



164
165
166
# File 'opal/stdlib/encoding.rb', line 164

def getbyte(idx)
  @encoding.getbyte(self, idx)
end

#to_nObject



375
376
377
# File 'opal/stdlib/native.rb', line 375

def to_n
  `self.valueOf()`
end