Sha256: 948e62d599ddc45bef0c7672fe8d647c5756582a39112d2fa4ad77ef4fd07187

Contents?: true

Size: 463 Bytes

Versions: 1

Compression:

Stored size: 463 Bytes

Contents

module RegXing
  class Generator
    attr_accessor :regex

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

    def generate!
      expression = regex.to_s
      str   = ""

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

      str
    end

    private

    def compile(el)
      if expr = RegXing::Regex.matchers.find {|exp, val| el.match(exp) }
        expr.last
      else
        el
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
regxing-0.0.1.beta lib/regxing/generator.rb