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.



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

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



93
94
95
# File 'lib/trenni/buffer.rb', line 93

def path
  @path
end

Instance Method Details

#encodingObject



95
96
97
# File 'lib/trenni/buffer.rb', line 95

def encoding
	read.encoding
end

#freezeObject



85
86
87
88
89
90
91
# File 'lib/trenni/buffer.rb', line 85

def freeze
	return self if frozen?
	
	read
	
	super
end

#readObject



99
100
101
# File 'lib/trenni/buffer.rb', line 99

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

#to_bufferObject



103
104
105
# File 'lib/trenni/buffer.rb', line 103

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