Class: DRP::MaxDepths::ProcMaxDepth
- Inherits:
-
Object
- Object
- DRP::MaxDepths::ProcMaxDepth
- Defined in:
- lib/weights_and_max_depths.rb
Instance Method Summary collapse
-
#initialize(proc) ⇒ ProcMaxDepth
constructor
A new instance of ProcMaxDepth.
- #value(drp_instance) ⇒ Object
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.).to_i else @proc.call(*Array.new(@arity) { drp_instance. }).to_i end end |