Class: Trenni::FileBuffer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileBuffer

Returns a new instance of FileBuffer.



52
53
54
# File 'lib/trenni/buffer.rb', line 52

def initialize(path)
	@path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



64
65
66
# File 'lib/trenni/buffer.rb', line 64

def path
  @path
end

Instance Method Details

#encodingObject



66
67
68
# File 'lib/trenni/buffer.rb', line 66

def encoding
	read.encoding
end

#freezeObject



56
57
58
59
60
61
62
# File 'lib/trenni/buffer.rb', line 56

def freeze
	return self if frozen?
	
	read
	
	super
end

#readObject



70
71
72
# File 'lib/trenni/buffer.rb', line 70

def read
	@cache ||= File.read(@path).freeze
end

#to_bufferObject



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

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