Class: Symbol

Inherits:
Object show all
Defined in:
lib/propr/random/symbol.rb,
lib/propr/shrink/symbol.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.random(options = {}, m = Propr::Random) ⇒ Object

@note: Beware of memory consumption. Symbols are never garbage collected, and we’re generating them at random!



5
6
7
8
9
10
11
12
# File 'lib/propr/random/symbol.rb', line 5

def random(options = {}, m = Propr::Random)
  min = options[:min] || 0
  max = options[:max] || 10
  options = Hash[charset: /[a-z_]/]
  m.bind(String.random(options)) do |s|
    m.unit(s.to_sym)
  end
end

Instance Method Details

#shrinkObject



2
3
4
# File 'lib/propr/shrink/symbol.rb', line 2

def shrink
  to_s.shrink.map(&:to_sym)
end