Class: CodinRep::EmployeeCommand
- Inherits:
-
Command
- Object
- Command
- CodinRep::EmployeeCommand
show all
- Defined in:
- lib/codin_rep/employee_command.rb
Defined Under Namespace
Classes: InvalidInteger, UnknownEmployeeOperation
Constant Summary
collapse
- CODE_MAX_SIZE =
12
Constants inherited
from Command
Command::COMMAND_PREFIX
Instance Method Summary
collapse
Methods inherited from Command
#generate_command_payload, #generate_header, #get_max_attempts, #get_timeout_time, #should_close_connection?
Constructor Details
Returns a new instance of EmployeeCommand.
47
48
49
50
|
# File 'lib/codin_rep/employee_command.rb', line 47
def initialize(*args)
super(*args)
@sent_registration = false
end
|
Instance Method Details
75
76
77
78
79
80
|
# File 'lib/codin_rep/employee_command.rb', line 75
def
= self.class::EXPECTED_HEADER
unless @response.match(/^#{}/)
raise UnknownHeader.new @response[0...size], 'set employee',
end
end
|
#execute ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/codin_rep/employee_command.rb', line 52
def execute
@command_data =
@command_data += generate_command_payload
@response = communicate!
@sent_registration = true
@command_data = self.class::REGISTRATION_COMPLETED_HEADER
@response = communicate!
sleep 0.1
return get_data_from_response_payload
rescue
@communication.close
raise
ensure
@communication.close if should_close_connection?
end
|
#get_data_from_response_payload ⇒ Object
86
87
88
|
# File 'lib/codin_rep/employee_command.rb', line 86
def get_data_from_response_payload
true
end
|
#get_expected_response_size ⇒ Object
71
72
73
|
# File 'lib/codin_rep/employee_command.rb', line 71
def get_expected_response_size
@sent_registration ? 0 : self.class::EXPECTED_HEADER.size
end
|
#get_response_payload ⇒ Object
82
83
84
|
# File 'lib/codin_rep/employee_command.rb', line 82
def get_response_payload
@sent_employee_data = true
end
|