Method: Randexp::Reducer.whitespace

Defined in:
lib/randexp/reducer.rb

.whitespace(quantity) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'lib/randexp/reducer.rb', line 68

def self.whitespace(quantity)
  case quantity
  when :'?'       then ['', Randgen.whitespace].pick
  when :+, :'+?'  then raise "Sorry, \"\\s+\" is too vague, try setting a range: \"\\s{1, 5}\""
  when :*, :'*?'  then raise "Sorry, \"\\s*\" is too vague, try setting a range: \"\\s{0, 5}\""
  when Range      then quantity.pick.of { Randgen.whitespace } * ''
  when Integer    then quantity.of { Randgen.whitespace } * ''
  when nil        then Randgen.whitespace
  end
end