class Buffer
Represents a string buffer with a given path.
Definitions
def initialize(string, path: "<string>")
Create a new buffer from a string.
Signature
-
parameter
stringString the string to use as the buffer.
-
parameter
pathString the path to use for the buffer.
Implementation
def initialize(string, path: "<string>")
@string = string
@path = path
end
attr :path
Signature
-
attribute
String the path name of the buffer.
def encoding
Signature
-
returns
Encoding the encoding of the buffer.
Implementation
def encoding
@string.encoding
end
def read
Signature
-
returns
String the content of the buffer.
Implementation
def read
@string
end
def self.load_file(path)
Create a buffer from the specified file.
Signature
-
parameter
pathString the path to load the file from.
-
returns
Buffer a buffer with the contents of the specified path.
Implementation
def self.load_file(path)
FileBuffer.new(path).freeze
end
def self.load(string)
Create a buffer from the specified string.
Signature
-
parameter
stringString the string to load into the buffer.
-
returns
Buffer a buffer with the contents of the specified string.
Implementation
def self.load(string)
Buffer.new(string).freeze
end
def to_buffer
Signature
-
returns
Buffer itself.
Implementation
def to_buffer
self
end