Sha256: fe9368a22502b3c687d3911051c00578525dbfab78b86fbb74cbf3911cc58339

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

module VirtualKeywords
  # Class that turns a sexp back into a string of Ruby code.
  class SexpStringifier
    # Initialize the SexpStringifier
    #
    # Arguments:
    #   unifier: (Unifier) a Unifier, used by ParseTree/ruby2ruby (optional)
    #   ruby2ruby: (Ruby2Ruby) a Ruby2Ruby, used by ParseTree/ruby2ruby
    #              (optional)
    def initialize(unifier = Unifier.new, ruby2ruby = Ruby2Ruby.new)
      @unifier = unifier
      @ruby2ruby = ruby2ruby
    end

    # Turn a sexp into a string of Ruby code.
    #
    # Arguments:
    #   sexp: (Sexp) the sexp to be stringified.
    #
    # Returns:
    #   (String) Ruby code equivalent to the sexp.
    def stringify sexp
      @ruby2ruby.process(@unifier.process(sexp))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
virtual_keywords-0.3.0 lib/virtual_keywords/sexp_stringifier.rb