Class: MemoryIO::Stream Private

Inherits:
Object
  • Object
show all
Defined in:
lib/memory_io/stream.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A stream tagged with the Context of the memory it accesses.

Types are handed one of these instead of the bare stream, so that a type can learn how to interpret the bytes it reads without the reading interface having to grow another argument.

Every other message is forwarded, so a stream behaves as it did before.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream, context) ⇒ Stream

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Stream.

Parameters:

  • stream (#read, #write)

    The stream to be tagged.

  • context (MemoryIO::Context)

    The context of the memory reached through stream.



21
22
23
24
# File 'lib/memory_io/stream.rb', line 21

def initialize(stream, context)
  @stream = stream
  @context = context
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
47
48
# File 'lib/memory_io/stream.rb', line 44

def method_missing(name, *, &)
  return super unless @stream.respond_to?(name)

  @stream.public_send(name, *, &)
end

Instance Attribute Details

#contextMemoryIO::Context (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



15
16
17
# File 'lib/memory_io/stream.rb', line 15

def context
  @context
end

Instance Method Details

#posObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'lib/memory_io/stream.rb', line 34

def pos
  @stream.pos
end

#pos=(val) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
# File 'lib/memory_io/stream.rb', line 38

def pos=(val)
  @stream.pos = val
end

#readObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
# File 'lib/memory_io/stream.rb', line 26

def read(*)
  @stream.read(*)
end

#writeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'lib/memory_io/stream.rb', line 30

def write(*)
  @stream.write(*)
end