Class: Trenni::IOBuffer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, path: io.inspect) ⇒ IOBuffer

Returns a new instance of IOBuffer.



72
73
74
75
# File 'lib/trenni/buffer.rb', line 72

def initialize(io, path: io.inspect)
	@io = io
	@path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



85
86
87
# File 'lib/trenni/buffer.rb', line 85

def path
  @path
end

Instance Method Details

#freezeObject



77
78
79
80
81
82
83
# File 'lib/trenni/buffer.rb', line 77

def freeze
	return self if frozen?
	
	read
	
	super
end

#readObject



87
88
89
# File 'lib/trenni/buffer.rb', line 87

def read
	@cache ||= @io.read.freeze
end

#to_bufferObject



91
92
93
# File 'lib/trenni/buffer.rb', line 91

def to_buffer
	Buffer.new(self.read, path: @path)
end