Class: TwitterCldr::Utils::RegexpSampler

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/utils/regexp_sampler.rb

Overview

Generates a valid string that would match the given regexp ast.

Constant Summary collapse

DIGITS =
('0'..'9').to_a
WORD_LETTERS =
('a'..'z').to_a + ('A'..'Z').to_a + ['_']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regexp_ast) ⇒ RegexpSampler

Returns a new instance of RegexpSampler.



17
18
19
# File 'lib/twitter_cldr/utils/regexp_sampler.rb', line 17

def initialize(regexp_ast)
  @regexp_ast = regexp_ast
end

Instance Attribute Details

#regexp_astObject (readonly)

Returns the value of attribute regexp_ast.



12
13
14
# File 'lib/twitter_cldr/utils/regexp_sampler.rb', line 12

def regexp_ast
  @regexp_ast
end

Instance Method Details

#generateObject



21
22
23
# File 'lib/twitter_cldr/utils/regexp_sampler.rb', line 21

def generate
  walk_children(regexp_ast)
end