Class: RubyScribe::Emitter
- Inherits:
-
Object
- Object
- RubyScribe::Emitter
- Includes:
- EmitterConfig, EmitterHelpers
- Defined in:
- lib/ruby_scribe/emitter.rb
Overview
Takes a proprocessed S-expression and emits formatted Ruby code
Instance Method Summary collapse
Methods included from EmitterConfig
Methods included from EmitterHelpers
#indent, #indent_level, #indents, #literalize_strings, #nl
Instance Method Details
#emit(e) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ruby_scribe/emitter.rb', line 9 def emit(e) return "" unless e return e if e.is_a?(String) return e.to_s if e.is_a?(Symbol) return e unless e.respond_to?(:kind) case e.kind when :block emit_block(e) when :scope emit_scope(e) when :ensure emit_rescue_ensure_wrapper(e) when :rescue emit_rescue(e) when :resbody emit_rescue_body(e) when :module emit_module_definition(e) when :class emit_class_definition(e) when :sclass emit_self_class_definition(e) when :defn emit_method_definition(e) when :defs emit_method_with_receiver_definition(e) when :args emit_method_argument_list(e) when :call emit_method_call(e) when :arglist emit_argument_list(e) when :attrasgn emit_attribute_assignment(e) when :cvasgn, :gasgn emit_class_variable_assignment(e) when :masgn emit_multiple_assignment(e) when :cdecl emit_constant_declaration(e) when :if emit_conditional_block(e) when :case emit_case_statement(e) when :when emit_case_when_statement(e) when :while, :until emit_loop_block(e) when :for emit_for_block(e) when :lasgn, :iasgn emit_assignment_expression(e) when :op_asgn1, :op_asgn2 emit_optional_assignment_expression(e) when :op_asgn_or emit_optional_assignment_or_expression(e) when :op_asgn_and emit_optional_assignment_and_expression(e) when :or, :and emit_binary_expression(e) when :iter emit_block_invocation(e) when :defined emit_defined_invocation(e) else emit_token(e) end || "" end |