Class: Ruckus::Mutator::Mutator
Overview
Create me with a String, and I wrap the string, forwarding method invocations to it. Call “permute” and I’ll run through my Modifier chain to derive a new value (for instance, tripling the number of characters).
Instance Method Summary collapse
-
#initialize(base = nil, stack = []) ⇒ Mutator
constructor
base
is usually a String (like “helu”) or Fixnum. - #method_missing(meth, *args) ⇒ Object
-
#permute ⇒ Object
A fuzzer clock tick; mess up the enclosed value.
Constructor Details
#initialize(base = nil, stack = []) ⇒ Mutator
base
is usually a String (like “helu”) or Fixnum. Stack is a set of modifier objects (or class names, if you just want to use the defaults). A Mutator with an empty Modifier stack doesn’t do anything and behaves just like an ordinary String or Fixnum.
36 37 38 39 40 41 42 43 |
# File 'lib/ruckus/mutator.rb', line 36 def initialize(base=nil, stack=[]) @base = base @cur = @base @stack = stack.map do |o| o = o.new if o.kind_of? Class o end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
45 46 47 |
# File 'lib/ruckus/mutator.rb', line 45 def method_missing(meth, *args) @cur.send(meth, *args) end |
Instance Method Details
#permute ⇒ Object
A fuzzer clock tick; mess up the enclosed value.
51 52 53 |
# File 'lib/ruckus/mutator.rb', line 51 def permute @cur = @stack.inject(@cur) {|cur, mod| mod << cur} end |