Class: MigemoRegex::RegexCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/migemo-regex.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegexCompiler

Returns a new instance of RegexCompiler.



45
46
47
# File 'lib/migemo-regex.rb', line 45

def initialize
  @regex = RegexAlternation.new
end

Instance Attribute Details

#regexObject (readonly)

Returns the value of attribute regex.



48
49
50
# File 'lib/migemo-regex.rb', line 48

def regex
  @regex
end

Instance Method Details

#optimize(level) ⇒ Object



60
61
62
63
64
# File 'lib/migemo-regex.rb', line 60

def optimize (level)
  @regex = optimize1(@regex) if level >= 1
  @regex = optimize2(@regex) if level >= 2
  @regex = optimize3(@regex) if level >= 3
end

#push(item) ⇒ Object



50
51
52
53
54
# File 'lib/migemo-regex.rb', line 50

def push (item)
  if item and item != ""
    @regex.push(item)
  end
end

#uniqObject



56
57
58
# File 'lib/migemo-regex.rb', line 56

def uniq
  @regex.uniq
end