Sha256: 084503ae5a776a5bde870ef7211a32f99dc0796e4c58d935e0e04cd68c93a841

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

class Navy::Officer < Navy::Rank
  attr_accessor :number, :officer_pid
  attr_reader :captain, :job
  def initialize(captain, number, job)
    @captain, @number, @job = captain, number, job
  end

  def ==(other_number)
    @number == other_number
  end

  def logger
    captain.logger
  end

  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
navy-1.1.2 lib/navy/officer.rb
navy-1.1.1 lib/navy/officer.rb