Module: RuneRb::IO::Readable
- Defined in:
- lib/rrb/io/readable.rb
Overview
Provides functions for reading integer values from a string-based buffer.
Instance Method Summary collapse
-
#read(type: :byte, signed: false, mutation: :STD, order: :BIG, options: {}) ⇒ Object
Read data from the payload according to the option parameter.
Instance Method Details
#read(type: :byte, signed: false, mutation: :STD, order: :BIG, options: {}) ⇒ Object
Read data from the payload according to the option parameter.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rrb/io/readable.rb', line 11 def read(type: :byte, signed: false, mutation: :STD, order: :BIG, options: {}) return unless RuneRb::IO::Validation.validate(self, 'read', { bit_access: @bit_access, mutation: mutation, order: order }) case type when :byte then read_byte(signed: signed, mutation: mutation) when :bytes then read_bytes([:amount] || 1, mutation: mutation) when :short then read_short(signed: signed, mutation: mutation, order: order) when :medium then read_medium(signed: signed, mutation: mutation, order: order) when :int then read_int(signed: signed, mutation: mutation, order: order) when :long then read_long(signed: signed, mutation: mutation, order: order) when :smart then read_smart(signed: signed, mutation: mutation) when :string then read_string when :reverse_bytes then read_bytes_reverse([:amount] || 1, mutation: mutation) else raise TypeError, "Unrecognized read type! Expected: [byte bytes short medium int long smart string reverse_bytes] | Received: #{type}" end end |