class Unparser::Emitter::Regexp

Emitter for regexp literals

Private Instance Methods

dispatch() click to toggle source
# File lib/unparser/emitter/regexp.rb, line 13
def dispatch
  parentheses('/', '/') do
    body.each(&method(:emit_body))
  end
  emit_options
end
emit_body(node) click to toggle source
# File lib/unparser/emitter/regexp.rb, line 24
def emit_body(node)
  if n_begin?(node)
    write('#{')
    node.children.each(&method(:visit))
    write('}')
  else
    buffer.append_without_prefix(node.children.first.gsub('/', '\/'))
  end
end
emit_options() click to toggle source
# File lib/unparser/emitter/regexp.rb, line 20
def emit_options
  write(children.last.children.join)
end