Class: RegXing::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/regxing/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regex) ⇒ Generator

Returns a new instance of Generator.



5
6
7
# File 'lib/regxing/generator.rb', line 5

def initialize(regex)
  @regex = RegXing::Regex.new(regex)
end

Instance Attribute Details

#regexObject

Returns the value of attribute regex.



3
4
5
# File 'lib/regxing/generator.rb', line 3

def regex
  @regex
end

Instance Method Details

#generate!Object



9
10
11
12
13
14
15
16
17
# File 'lib/regxing/generator.rb', line 9

def generate!
  str   = ""

  regex.split.each do |el|
    str << compile(el.first) * el.last
  end

  str
end