Module: RuneRb::IO::Writeable
- Defined in:
- lib/rrb/io/writeable.rb
Overview
Instance Method Summary collapse
-
#finish_access ⇒ Object
Completes bit access.
-
#switch_access ⇒ Object
Enables or Disables bit writing by setting the Buffer#bit_access variable.
-
#write(value, type: :byte, mutation: :STD, order: :BIG, options: {}) ⇒ RuneRb::IO::Message, RuneRb::IO::Writeable
Write data to the payload.
Instance Method Details
#finish_access ⇒ Object
Completes bit access.
40 41 42 43 44 |
# File 'lib/rrb/io/writeable.rb', line 40 def finish_access @bit_position = (@bit_position + 7) / 8 switch_access self end |
#switch_access ⇒ Object
Enables or Disables bit writing by setting the Buffer#bit_access variable.
34 35 36 37 |
# File 'lib/rrb/io/writeable.rb', line 34 def switch_access @bit_access = !@bit_access self end |
#write(value, type: :byte, mutation: :STD, order: :BIG, options: {}) ⇒ RuneRb::IO::Message, RuneRb::IO::Writeable
Write data to the payload.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rrb/io/writeable.rb', line 12 def write(value, type: :byte, mutation: :STD, order: :BIG, options: {}) return unless RuneRb::IO::Validation.validate(self, 'write', { mutation: mutation, order: order }) case type when :bits then write_bits(value, [:amount] || 1) when :bit then write_bit(value) when :byte then write_byte(value, mutation: mutation) when :bytes then write_bytes(value) when :short then write_short(value, mutation: mutation, order: order) when :medium then write_medium(value, mutation: mutation, order: order) when :int then write_int(value, mutation: mutation, order: order) when :long then write_long(value, mutation: mutation, order: order) when :smart then write_smart(value, mutation: mutation, signed: [:signed] || false) when :string then write_string(value) when :reverse_bytes then write_reverse_bytes(value) else raise "Unrecognized write type! #{type}" end self end |