Module: Unparser
- Defined in:
- lib/unparser.rb,
lib/unparser/buffer.rb,
lib/unparser/emitter.rb,
lib/unparser/comments.rb,
lib/unparser/constants.rb,
lib/unparser/emitter/if.rb,
lib/unparser/emitter/def.rb,
lib/unparser/emitter/for.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/send/regular.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, Comments, Emitter
Constant Summary collapse
- EMPTY_STRING =
''.freeze
- EMPTY_ARRAY =
[].freeze
Class Method Summary collapse
-
.transquote(raw_quoted, current_delimiter, target_delimiter) ⇒ String
private
Transquote string.
-
.unparse(node, comment_array = []) ⇒ String
private
Unparse an AST (and, optionally, comments) into a 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
42 43 44 45 |
# File 'lib/unparser.rb', line 42 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, comment_array = []) ⇒ 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 an AST (and, optionally, comments) into a string
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/unparser.rb', line 21 def self.unparse(node, comment_array = []) if node.nil? node = Parser::AST::Node.new(:empty) end buffer = Buffer.new comments = Comments.new(comment_array) root = Emitter::Root.new(buffer, comments) Emitter.emitter(node, root).write_to_buffer buffer.content end |