Class: QuelinkMg::Resp::Gtgsv

Inherits:
Base
  • Object
show all
Defined in:
lib/quelink-mg/resp/gtgsv.rb

Constant Summary collapse

GTGSV_RESP_KEYS_PREFIX =
%w[protocol_version unique_id device_name sv_count].freeze
GTGSV_RESP_KEYS_SUFFIX =
%w[send_time count_number].freeze

Constants inherited from Base

Base::QUELINK_DATE_FORMAT

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from QuelinkMg::Resp::Base

Instance Method Details

#hashObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/quelink-mg/resp/gtgsv.rb', line 9

def hash
  all_params = @response.split(',')

  sv_out = all_params[3].to_i

  sv_arr = []
  sv_out.times do |i|
    sv_arr << "sv_id_#{i}"
    sv_arr << "sv_power_#{i}"
  end

  keys = [GTGSV_RESP_KEYS_PREFIX, sv_arr, GTGSV_RESP_KEYS_SUFFIX].inject(:+)

  unify_keys(keys.zip(all_params).to_h)
end