Class: MigemoRegex::RegexRenderer
- Inherits:
-
Object
- Object
- MigemoRegex::RegexRenderer
- Defined in:
- lib/migemo-regex.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#with_paren ⇒ Object
Returns the value of attribute with_paren.
Instance Method Summary collapse
-
#initialize(regex, insertion) ⇒ RegexRenderer
constructor
A new instance of RegexRenderer.
- #join_regexes(string, regexes) ⇒ Object
- #render ⇒ Object
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_paren ⇒ Object
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. end |
#render ⇒ Object
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. end end |