Sha256: 1f38113ce8fbdc5cd418315fbaeb5c5f90e63b44e730e7d3b34a0014d74a5845

Contents?: true

Size: 810 Bytes

Versions: 14

Compression:

Stored size: 810 Bytes

Contents

require_relative "method_call"
require_relative "wraps_sexp"

module CutePrint
  class RubyParser

    # How this class works is cribbed this excellent code:
    #
    #     https://github.com/sconover/wrong/blob/30475fc5ac9d0f73135d229b1b44c045156a7e7a/lib/wrong/d.rb
    #
    # @api private

    class ParsedCode

      include WrapsSexp

      def first_call_to_method(method_name)
        MethodCall.new(method_call_node(method_name))
      end

      private

      def method_call_node(method_name)
        if MethodCall.call_to_method?(@sexp, method_name)
          return @sexp
        end
        @sexp.each_sexp do |node|
          if MethodCall.call_to_method?(node, method_name)
            return node
          end
        end
        raise "Method call not found"
      end

    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
cute_print-1.4.0 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.3.0 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.2.0 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.1.4 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.1.3 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.1.2 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.1.1 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.1.0 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.0.1 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-1.0.0 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-0.4.0 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-0.3.0 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-0.2.0 lib/cute_print/ruby_parser/parsed_code.rb
cute_print-0.1.0 lib/cute_print/ruby_parser/parsed_code.rb