Class: RegXing::Generator
- Inherits:
-
Object
- Object
- RegXing::Generator
- Defined in:
- lib/regxing/generator.rb
Instance Attribute Summary collapse
-
#regex ⇒ Object
Returns the value of attribute regex.
Instance Method Summary collapse
- #generate! ⇒ Object
-
#initialize(regex) ⇒ Generator
constructor
A new instance of Generator.
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
#regex ⇒ Object
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 |