Class: McProtocolE::Frame3e::BatchReadInWord
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- McProtocolE::Frame3e::BatchReadInWord
- 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
-
#initialize(device_range:) ⇒ BatchReadInWord
constructor
Constructor.
-
#parse(res) ⇒ Object
Returns array of word.
-
#to_b ⇒ String
Returns binary string.
Constructor Details
#initialize(device_range:) ⇒ BatchReadInWord
Constructor.
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
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_b ⇒ String
Returns 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 |