Class: XRB::FileBuffer
- Inherits:
-
Object
- Object
- XRB::FileBuffer
- Defined in:
- lib/xrb/buffer.rb
Overview
Represents a file 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
Instance Method Summary collapse
- #encoding ⇒ Object
-
#freeze ⇒ Object
Freeze the buffer, caching the contents of the file.
-
#initialize(path) ⇒ FileBuffer
constructor
Create a new file buffer from a file path.
-
#read ⇒ Object
Read the contents of the file into the buffer.
- #to_buffer ⇒ Object
Constructor Details
#initialize(path) ⇒ FileBuffer
Create a new file buffer from a file path.
65 66 67 68 |
# File 'lib/xrb/buffer.rb', line 65 def initialize(path) @path = path @cache = nil end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
80 81 82 |
# File 'lib/xrb/buffer.rb', line 80 def path @path end |
#the path name of the buffer.(pathnameofthebuffer.) ⇒ Object (readonly)
80 |
# File 'lib/xrb/buffer.rb', line 80 attr :path |
Instance Method Details
#encoding ⇒ Object
83 84 85 |
# File 'lib/xrb/buffer.rb', line 83 def encoding read.encoding end |
#freeze ⇒ Object
Freeze the buffer, caching the contents of the file.
71 72 73 74 75 76 77 |
# File 'lib/xrb/buffer.rb', line 71 def freeze return self if frozen? read super end |
#read ⇒ Object
Read the contents of the file into the buffer.
89 90 91 |
# File 'lib/xrb/buffer.rb', line 89 def read @cache ||= File.read(@path).freeze end |