Module: RuneRb::System::Patches::Readable

Includes:
Network::Constants
Defined in:
app/system/patches/readable.rb

Overview

Since:

  • 0.9.3

Constant Summary

Constants included from Network::Constants

Network::Constants::BIT_MASK_OUT, Network::Constants::BYTE_MUTATIONS, Network::Constants::BYTE_ORDERS, Network::Constants::BYTE_SIZE, Network::Constants::CONNECTION_TYPES, Network::Constants::LOGIN_RESPONSES, Network::Constants::MESSAGE_SIZES, Network::Constants::PROTOCOL_TEMPLATES, Network::Constants::RW_TYPES, Network::Constants::SIDEBAR_INTERFACES

Instance Method Summary collapse

Instance Method Details

#parseObject

This method is abstract.

parses the message object.

Since:

  • 0.9.3


37
# File 'app/system/patches/readable.rb', line 37

def parse; end

#push_data(data) ⇒ Object

Appends data directly to the <@payload>

Since:

  • 0.9.3


32
33
34
# File 'app/system/patches/readable.rb', line 32

def push_data(data)
  @payload << data
end

#read(type = :byte, opt = { signed: false, mutation: :STD, order: :BIG }) ⇒ Object

Read database from the payload according to the option parameter.

Parameters:

  • type (Symbol) (defaults to: :byte)

    the type of database to read

  • opt (Hash) (defaults to: { signed: false, mutation: :STD, order: :BIG })

    options that are to be observed when reading the database.

Since:

  • 0.9.3


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/system/patches/readable.rb', line 8

def read(type = :byte, opt = { signed: false, mutation: :STD, order: :BIG })
  return unless RuneRb::Network::Message.validate(self, :read, opt)

  case type
  when *RW_TYPES[:byte] then read_byte(opt[:signed] || false, opt[:mutation] || :STD)
  when *RW_TYPES[:short] then read_short(opt[:signed] || false, opt[:mutation] || :STD, opt[:order] || :BIG)
  when *RW_TYPES[:medium] then read_medium(opt[:signed] || false, opt[:mutation] || :STD, opt[:order] || :BIG)
  when *RW_TYPES[:int] then read_int(opt[:signed] || false, opt[:mutation] || :STD, opt[:order] || :BIG)
  when *RW_TYPES[:long] then read_long(opt[:signed] || false, opt[:mutation] || :STD, opt[:order] || :BIG)
  when *RW_TYPES[:string] then read_string
  when :bytes then read_bytes(opt[:amount], opt[:mutation])
  when :reverse_bytes, :negative_bytes, :reverse, :negatives then read_bytes_reverse(opt[:amount] || opt[:length], opt[:mutation])
  when :io, :socket then read_from(opt[:io] || opt[:source] || opt[:socket], opt[:length])
  when :header then read_header(opt[:source])
  else raise "Unrecognized read type! #{type}"
  end
end

#readable?Boolean

Ensure the message is considered readable

Returns:

  • (Boolean)

Since:

  • 0.9.3


27
28
29
# File 'app/system/patches/readable.rb', line 27

def readable?
  true
end