Class: HaveAPI::Fs::Components::RemoteControlFile::FileHandle
- Inherits:
-
Object
- Object
- HaveAPI::Fs::Components::RemoteControlFile::FileHandle
- Defined in:
- lib/haveapi/fs/components/remote_control_file.rb
Instance Attribute Summary collapse
-
#read_buf ⇒ Object
Returns the value of attribute read_buf.
-
#write_buf ⇒ Object
Returns the value of attribute write_buf.
Instance Method Summary collapse
- #complete? ⇒ Boolean
-
#initialize ⇒ FileHandle
constructor
A new instance of FileHandle.
- #parse ⇒ Object
- #read(offset, size) ⇒ Object
- #write(offset, size, buf) ⇒ Object
Constructor Details
#initialize ⇒ FileHandle
Returns a new instance of FileHandle.
19 20 21 22 |
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 19 def initialize @read_buf = '' @write_buf = '' end |
Instance Attribute Details
#read_buf ⇒ Object
Returns the value of attribute read_buf.
16 17 18 |
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 16 def read_buf @read_buf end |
#write_buf ⇒ Object
Returns the value of attribute write_buf.
17 18 19 |
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 17 def write_buf @write_buf end |
Instance Method Details
#complete? ⇒ Boolean
32 33 34 |
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 32 def complete? @write_buf.end_with?(MSG_DELIMITER) end |
#parse ⇒ Object
36 37 38 39 40 |
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 36 def parse cmd = YAML.load(@write_buf[0..(-1 - MSG_DELIMITER.size)]) @write_buf.clear cmd end |
#read(offset, size) ⇒ Object
24 25 26 |
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 24 def read(offset, size) @read_buf[offset, size] end |
#write(offset, size, buf) ⇒ Object
28 29 30 |
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 28 def write(offset, size, buf) @write_buf[offset, size] = buf end |