Class: DRP::MaxDepths::ProcMaxDepth

Inherits:
Object
  • Object
show all
Defined in:
lib/weights_and_max_depths.rb

Instance Method Summary collapse

Constructor Details

#initialize(proc) ⇒ ProcMaxDepth

Returns a new instance of ProcMaxDepth.



55
56
57
# File 'lib/weights_and_max_depths.rb', line 55

def initialize proc
  @proc, @arity = proc, proc.arity
end

Instance Method Details

#value(drp_instance) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/weights_and_max_depths.rb', line 58

def value drp_instance
  if @arity <= 0
    @proc.call.to_i
  elsif @arity == 1
    @proc.call(drp_instance.next_meta_codon).to_i
  else
    @proc.call(*Array.new(@arity) { drp_instance.next_meta_codon }).to_i
  end
end