Class: MigemoRegex::RegexRenderer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regex, insertion) ⇒ RegexRenderer

Returns a new instance of RegexRenderer.



175
176
177
178
179
180
181
# File 'lib/migemo-regex.rb', line 175

def initialize (regex, insertion)
  raise if regex == nil
  @regex = regex
  @meta = RegexMetachars.new
  @insertion = insertion
  @with_paren = false
end

Instance Attribute Details

#with_parenObject

Returns the value of attribute with_paren.



182
183
184
# File 'lib/migemo-regex.rb', line 182

def with_paren
  @with_paren
end

Instance Method Details

#join_regexes(string, regexes) ⇒ Object



194
195
196
# File 'lib/migemo-regex.rb', line 194

def join_regexes (string, regexes)
  ([string] + regexes).join @meta.bar
end

#renderObject



184
185
186
187
188
189
190
191
192
# File 'lib/migemo-regex.rb', line 184

def render
  if @with_paren  # e.g. "(a|b|c)"
    render0(@regex)
  else            # e.g. "a|b|c"
    @regex.map do |x|
      render0(x)
    end.join @meta.bar
  end
end