Class: McProtocolE::Frame3e::BatchReadInWord

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/mc_protocol_e/frame_3e/batch_read_in_word.rb

Overview

This class shows a command to batch read in word.

Constant Summary collapse

COMMAND =
"\x01\x04\x00\x00".b

Instance Method Summary collapse

Constructor Details

#initialize(device_range:) ⇒ BatchReadInWord

Constructor.

Parameters:



14
15
16
17
# File 'lib/mc_protocol_e/frame_3e/batch_read_in_word.rb', line 14

def initialize(device_range:)
  super(COMMAND)
  @device_range = device_range
end

Instance Method Details

#parse(res) ⇒ Object

Returns array of word. @return array of word

Parameters:



22
23
24
25
26
# File 'lib/mc_protocol_e/frame_3e/batch_read_in_word.rb', line 22

def parse(res)
  super(res)

  res.data&.each_char&.each_slice(2)&.map(&:join)
end

#to_bString

Returns binary string.

Returns:

  • (String)

    binary string



30
31
32
# File 'lib/mc_protocol_e/frame_3e/batch_read_in_word.rb', line 30

def to_b
  @to_b ||= command + device_range.to_b
end