Sha256: 77f8d7ba6cf0e816e17d5c7f28546655c71fe15fde8cb63add7400aefbc3f6b1
Contents?: true
Size: 1.86 KB
Versions: 2
Compression:
Stored size: 1.86 KB
Contents
# encoding: utf-8 module Unparser class Emitter class Literal # Base class for primitive emitters class Primitive < self children :value private # Emitter for primitives based on Object#inspect class Inspect < self handle :float, :int, :sym private # Dispatch value # # @return [undefined] # # @api private # def dispatch write(value.inspect) end end # Inspect # Literal emitter with macro regeneration base class class MacroSafe < self private # Perform dispatch # # @return [undefined] # # @api private # def dispatch if source == macro write(macro) return end write(value.inspect) end # Return source, if present # # @return [String] # if present # # @return [nil] # otherwise # # @api private # def source location = node.location || return expression = location.expression || return expression.source end # Return marco # # @return [String] # # @api private # def macro self.class::MACRO end # String macro safe emitter class String < self MACRO = '__FILE__'.freeze handle :str end # String # Integer macro safe emitter class Integer < self MACRO = '__LINE__'.freeze handle :int end # Integer end # MacroSave end # Primitive end # Literal end # Emitter end # Unparser
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unparser-0.1.7 | lib/unparser/emitter/literal/primitive.rb |
unparser-0.1.6 | lib/unparser/emitter/literal/primitive.rb |