Class: Ruvi::BufferListing

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/buffer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBufferListing

Returns a new instance of BufferListing.



10
11
12
13
# File 'lib/buffer.rb', line 10

def initialize
    @id2buffer = {}
    @open_buffers = []
end

Instance Attribute Details

#open_buffersObject (readonly)

Returns the value of attribute open_buffers.



9
10
11
# File 'lib/buffer.rb', line 9

def open_buffers
  @open_buffers
end

Instance Method Details

#<<(buffer) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/buffer.rb', line 21

def << buffer
    @id2buffer[buffer.id] = buffer
    @open_buffers << buffer
    ObjectSpace.define_finalizer buffer, 
                                 proc { 
                                     |id|
                                     # puts "killing buffer #{id}"
                                     self.delete buffer
                                 }
end

#clearObject



18
19
20
# File 'lib/buffer.rb', line 18

def clear
    @open_buffers.clear
end

#delete(buffer) ⇒ Object



14
15
16
17
# File 'lib/buffer.rb', line 14

def delete buffer
    @id2buffer 
    @open_buffers.delete buffer
end