Class: XRB::Buffer
- Inherits:
-
Object
- Object
- XRB::Buffer
- Defined in:
- lib/xrb/buffer.rb
Overview
Represents a string buffer with a given path.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
- #the path name of the buffer.(pathnameofthebuffer.) ⇒ Object readonly
Class Method Summary collapse
-
.load(string) ⇒ Object
Create a buffer from the specified string.
-
.load_file(path) ⇒ Object
Create a buffer from the specified file.
Instance Method Summary collapse
- #encoding ⇒ Object
-
#freeze ⇒ Object
Freeze the buffer and its contents.
-
#initialize(string, path: "<string>") ⇒ Buffer
constructor
Create a new buffer from a string.
- #read ⇒ Object
- #to_buffer ⇒ Object
Constructor Details
#initialize(string, path: "<string>") ⇒ Buffer
Create a new buffer from a string.
12 13 14 15 |
# File 'lib/xrb/buffer.rb', line 12 def initialize(string, path: "<string>") @string = string @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
18 19 20 |
# File 'lib/xrb/buffer.rb', line 18 def path @path end |
#the path name of the buffer.(pathnameofthebuffer.) ⇒ Object (readonly)
18 |
# File 'lib/xrb/buffer.rb', line 18 attr :path |
Class Method Details
.load(string) ⇒ Object
Create a buffer from the specified string.
51 52 53 |
# File 'lib/xrb/buffer.rb', line 51 def self.load(string) Buffer.new(string).freeze end |
.load_file(path) ⇒ Object
Create a buffer from the specified file.
44 45 46 |
# File 'lib/xrb/buffer.rb', line 44 def self.load_file(path) FileBuffer.new(path).freeze end |
Instance Method Details
#encoding ⇒ Object
32 33 34 |
# File 'lib/xrb/buffer.rb', line 32 def encoding @string.encoding end |
#freeze ⇒ Object
Freeze the buffer and its contents.
22 23 24 25 26 27 28 29 |
# File 'lib/xrb/buffer.rb', line 22 def freeze return self if frozen? @string.freeze @path.freeze super end |
#read ⇒ Object
37 38 39 |
# File 'lib/xrb/buffer.rb', line 37 def read @string end |
#to_buffer ⇒ Object
56 57 58 |
# File 'lib/xrb/buffer.rb', line 56 def to_buffer self end |