Class: Navy::Officer
Instance Attribute Summary collapse
-
#captain ⇒ Object
readonly
Returns the value of attribute captain.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#number ⇒ Object
Returns the value of attribute number.
-
#officer_pid ⇒ Object
Returns the value of attribute officer_pid.
Attributes inherited from Rank
#after_fork, #after_stop, #before_fork, #before_stop, #current_stderr, #current_stdout, #heartbeat, #options, #orders, #orig_stderr, #orig_stdout, #patience, #pid, #post_fork, #preload, #reexec_pid, #respawn_limit, #respawn_limit_seconds, #stderr_path, #stdout_path, #timeout
Instance Method Summary collapse
- #==(other_number) ⇒ Object
-
#initialize(captain, number, job) ⇒ Officer
constructor
A new instance of Officer.
- #logger ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(captain, number, job) ⇒ Officer
Returns a new instance of Officer.
4 5 6 |
# File 'lib/navy/officer.rb', line 4 def initialize(captain, number, job) @captain, @number, @job = captain, number, job end |
Instance Attribute Details
#captain ⇒ Object (readonly)
Returns the value of attribute captain.
3 4 5 |
# File 'lib/navy/officer.rb', line 3 def captain @captain end |
#job ⇒ Object (readonly)
Returns the value of attribute job.
3 4 5 |
# File 'lib/navy/officer.rb', line 3 def job @job end |
#number ⇒ Object
Returns the value of attribute number.
2 3 4 |
# File 'lib/navy/officer.rb', line 2 def number @number end |
#officer_pid ⇒ Object
Returns the value of attribute officer_pid.
2 3 4 |
# File 'lib/navy/officer.rb', line 2 def officer_pid @officer_pid end |
Instance Method Details
#==(other_number) ⇒ Object
8 9 10 |
# File 'lib/navy/officer.rb', line 8 def ==(other_number) @number == other_number end |
#logger ⇒ Object
12 13 14 |
# File 'lib/navy/officer.rb', line 12 def logger captain.logger end |
#start ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/navy/officer.rb', line 16 def start self.officer_pid = $$ proc_name "(#{captain.label}) officer[#{number}]" (job.respond_to?(:arity) && job.arity == 0) ? job.call : job.call(self) rescue => e Navy.log_error(logger, "(#{captain.label}) officer[#{number}] loop error", e) rescue nil exit! end |