Class: MigemoRegex::RegexCompiler
- Inherits:
-
Object
- Object
- MigemoRegex::RegexCompiler
- Defined in:
- lib/migemo-regex.rb
Instance Attribute Summary collapse
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
Instance Method Summary collapse
-
#initialize ⇒ RegexCompiler
constructor
A new instance of RegexCompiler.
- #optimize(level) ⇒ Object
- #push(item) ⇒ Object
- #uniq ⇒ Object
Constructor Details
#initialize ⇒ RegexCompiler
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
#regex ⇒ Object (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 |
#uniq ⇒ Object
56 57 58 |
# File 'lib/migemo-regex.rb', line 56 def uniq @regex.uniq end |