Class: HaveAPI::Fs::Components::RemoteControlFile::FileHandle

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/fs/components/remote_control_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFileHandle

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_bufObject

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_bufObject

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

Returns:

  • (Boolean)


32
33
34
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 32

def complete?
  @write_buf.end_with?(MSG_DELIMITER)
end

#parseObject



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