Class: DFuzz::Char

Inherits:
Generator show all
Defined in:
lib/dfuzz/char.rb

Instance Method Summary collapse

Methods inherited from Generator

#current, #each, #empty?, #end?, #index, #next, #next?, #pos, #rewind, #shift, #yield

Constructor Details

#initialize(c = :default) ⇒ Char

Returns a new instance of Char.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dfuzz/char.rb', line 3

def initialize(c=:default)
  c = case c
  when :all
    (0..256).map(&:chr)
  when :alpha
    ('A'..'Z').to_a + ('a'..'z').to_a
  when Enumerator
    c
  when ::String
    c.chars
  when :default
    ["A", "0", "~", "`", "!", "@", "#", "$", "%", "^", "&",
     "*", "(", ")", "-", "=", "+", "[", "]", "|",
     ":", "'", "\"", ",", "<", ".", ">", "/",
     " ", "~", "_", "{", "}", "\x7f","\x00",
     "\x88","\x89","\x8f",
     "\x98","\x99","\x9f",
     "\xa8","\xa9","\xaf",
     "\xb8","\xb9","\xbf",
     "\xc8","\xc9","\xcf",
     "\xd8","\xd9","\xdf",
     "\xe8","\xe9","\xef",
     "\xf8","\xf9","\xff"
   ]
  else
    c.to_enum
  end
  super() {|yldr|
    c.each do |char|
      yldr.yield char
    end
  }
end