class JvmBytecode::Constants::Utf8

Public Class Methods

decode(io) click to toggle source
# File lib/jvm_bytecode/constants/utf8.rb, line 6
def self.decode(io)
  str = io.read(io.read(2).unpack('S>').first).force_encoding('UTF-8')
  new(str)
end
new(str) click to toggle source
# File lib/jvm_bytecode/constants/utf8.rb, line 11
def initialize(str)
  raise "#{self.class} requires utf-8 string" unless str.encoding.to_s == 'UTF-8'
  @str = str
end

Public Instance Methods

additional_bytecode() click to toggle source
# File lib/jvm_bytecode/constants/utf8.rb, line 20
def additional_bytecode
  s = @str.dup.force_encoding('ASCII-8BIT')
  [s.length].pack('S>') + s
end
to_hash() click to toggle source
# File lib/jvm_bytecode/constants/utf8.rb, line 25
def to_hash
  { string: @str }
end
to_s() click to toggle source
# File lib/jvm_bytecode/constants/utf8.rb, line 16
def to_s
  @str
end