Class: DRP::Weights::StaticWeight

Inherits:
AbstractWeight show all
Defined in:
lib/weights_and_max_depths.rb

Overview

weight 10.0 static weight

weight 0..1                         static mapped
weight 0..1, :function              static mapped w/ function
weight {}                           static proc gets codons

Direct Known Subclasses

ProcStaticWeight

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractWeight

factory

Constructor Details

#initialize(args) ⇒ StaticWeight

Returns a new instance of StaticWeight.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/weights_and_max_depths.rb', line 93

def initialize args
  user_args = args.user_args
  sz = user_args.size
  case sz
    when 1
      arg = user_args[0]
      case arg
        when Numeric
          @value = arg.to_f
        when Range
          @value = Utils::map(
            arg, 
            args.drp_instance.next_meta_codon
          )
        else 
          raise ArgumentError, 'when 1 arg given to weight, must be Numeric, or Range', caller
      end
    when 2
      rng = args[0] 
      func = args[1].to_sym
      if (rng.kind_of? Range) && (func.kind_of? Symbol)
        @value = Utils::map(
          rng, 
          args.drp_instance.next_meta_codon,
          func
        )
      else
        raise ArgumentError, 'weight args of wrong types'
      end
    else
    raise ArgumentError, "weight takes 1 or 2 args, #{sz} given"
  end # case user_args.size
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



92
93
94
# File 'lib/weights_and_max_depths.rb', line 92

def value
  @value
end