class Takumi::Packet::String

Public Class Methods

decode(source) click to toggle source
# File lib/takumi/packet/string.rb, line 5
def decode(source)
  size, read = ::Takumi::Packet::Varint.decode(source)
  return source[read, size], (size + read)
end
new(str) click to toggle source
# File lib/takumi/packet/string.rb, line 11
def initialize(str)
  @str = str
end

Public Instance Methods

to_s() click to toggle source
# File lib/takumi/packet/string.rb, line 15
def to_s
  packet = "".encode(Encoding::BINARY)
  packet << ::Takumi::Packet::Varint.new(@str.bytesize).to_s
  packet << @str.dup.force_encoding(Encoding::BINARY)
end