Class: CodinRep::GetAfdHeader

Inherits:
GetRecords show all
Defined in:
lib/codin_rep/get_afd_header.rb

Constant Summary collapse

ONLY_RECORD_COMMAND =
"PGREP009Z".freeze

Constants inherited from GetRecords

CodinRep::GetRecords::AFD_DATA_CONTINUATION_HEADER, CodinRep::GetRecords::AFD_DATA_END_HEADER, CodinRep::GetRecords::AFD_DATA_ONLY_HEADER, CodinRep::GetRecords::AFD_DATA_START_HEADER, CodinRep::GetRecords::AFD_SIZES_BY_TYPE, CodinRep::GetRecords::END_HEADER, CodinRep::GetRecords::HEADER_SIZE, CodinRep::GetRecords::NEXT_RECORD_COMMAND, CodinRep::GetRecords::START_COMMAND, CodinRep::GetRecords::START_HEADER

Constants inherited from Command

Command::COMMAND_PREFIX

Instance Method Summary collapse

Methods inherited from GetRecords

#get_afd_data_type_size, #get_afd_records, #get_expected_response_size, #get_response_payload

Methods inherited from Command

#check_response_header, #generate_command_payload, #generate_header, #get_data_from_response_payload, #get_expected_response_size, #get_max_attempts, #get_timeout_time, #should_close_connection?

Constructor Details

#initialize(*args) ⇒ GetAfdHeader

Returns a new instance of GetAfdHeader.



27
28
29
# File 'lib/codin_rep/get_afd_header.rb', line 27

def initialize(*args)
  super(nil, *args)
end

Instance Method Details

#executeObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/codin_rep/get_afd_header.rb', line 35

def execute
  @command_data = get_first_command
  @response = ""
  @parser = AfdParser.new(false)
  @records = []

  begin
    @response = communicate!
    @command_data = ONLY_RECORD_COMMAND
    @response = communicate!
    raw_record = get_response_payload
    current_record = @parser.parse_line(raw_record, nil)
    return current_record
  ensure
    @communication.close if @communication
  end
end

#get_first_commandObject



31
32
33
# File 'lib/codin_rep/get_afd_header.rb', line 31

def get_first_command
  "#{START_COMMAND}000000000000000001"
end