Module: Unparser
- Defined in:
- lib/unparser.rb,
lib/unparser/buffer.rb,
lib/unparser/emitter.rb,
lib/unparser/constants.rb,
lib/unparser/emitter/if.rb,
lib/unparser/emitter/def.rb,
lib/unparser/emitter/for.rb,
lib/unparser/emitter/not.rb,
lib/unparser/emitter/case.rb,
lib/unparser/emitter/next.rb,
lib/unparser/emitter/redo.rb,
lib/unparser/emitter/root.rb,
lib/unparser/emitter/send.rb,
lib/unparser/emitter/alias.rb,
lib/unparser/emitter/begin.rb,
lib/unparser/emitter/block.rb,
lib/unparser/emitter/break.rb,
lib/unparser/emitter/cbase.rb,
lib/unparser/emitter/class.rb,
lib/unparser/emitter/empty.rb,
lib/unparser/emitter/match.rb,
lib/unparser/emitter/retry.rb,
lib/unparser/emitter/splat.rb,
lib/unparser/emitter/super.rb,
lib/unparser/emitter/undef.rb,
lib/unparser/emitter/yield.rb,
lib/unparser/emitter/binary.rb,
lib/unparser/emitter/ensure.rb,
lib/unparser/emitter/module.rb,
lib/unparser/emitter/rescue.rb,
lib/unparser/emitter/return.rb,
lib/unparser/emitter/defined.rb,
lib/unparser/emitter/hookexe.rb,
lib/unparser/emitter/literal.rb,
lib/unparser/emitter/resbody.rb,
lib/unparser/emitter/argument.rb,
lib/unparser/emitter/flipflop.rb,
lib/unparser/emitter/variable.rb,
lib/unparser/emitter/op_assign.rb,
lib/unparser/emitter/assignment.rb,
lib/unparser/emitter/repetition.rb,
lib/unparser/emitter/send/index.rb,
lib/unparser/emitter/send/unary.rb,
lib/unparser/emitter/send/binary.rb,
lib/unparser/emitter/literal/range.rb,
lib/unparser/emitter/literal/regexp.rb,
lib/unparser/emitter/literal/dynamic.rb,
lib/unparser/emitter/literal/composed.rb,
lib/unparser/emitter/literal/primitive.rb,
lib/unparser/emitter/literal/singleton.rb,
lib/unparser/emitter/literal/dynamic_body.rb,
lib/unparser/emitter/literal/execute_string.rb
Overview
Library namespace
Defined Under Namespace
Modules: Constants Classes: Buffer, Emitter
Constant Summary collapse
- EMPTY_STRING =
''.freeze
Class Method Summary collapse
-
.transquote(raw_quoted, current_delimiter, target_delimiter) ⇒ String
private
Transquote string.
-
.unparse(node) ⇒ String
private
Unparse ast into string.
Class Method Details
.transquote(raw_quoted, current_delimiter, target_delimiter) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Transquote string
37 38 39 40 |
# File 'lib/unparser.rb', line 37 def self.transquote(raw_quoted, current_delimiter, target_delimiter) raw = raw_quoted.gsub("\\#{current_delimiter}", current_delimiter) raw.gsub(target_delimiter, "\\#{target_delimiter}").freeze end |
.unparse(node) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Unparse ast into string
18 19 20 21 22 23 24 25 |
# File 'lib/unparser.rb', line 18 def self.unparse(node) if node.nil? node = Parser::AST::Node.new(:empty) end buffer = Buffer.new Emitter.visit(node, buffer) buffer.content end |