Sha256: b8cfc2cb19c4565feaec6a7edae2bcb690a2422cbc1342f71d48265d5c126d97

Contents?: true

Size: 455 Bytes

Versions: 11

Compression:

Stored size: 455 Bytes

Contents

require_relative "ruby_parser"

module CutePrint
  # @api private
  class SourceLabel

    def initialize(block, method)
      @block = block
      @method = method
    end

    def to_s
      "#{block_code} is "
    end

    private

    def block_code
      ruby_parser = RubyParser.from_block(@block)
      parsed_code = ruby_parser.parse
      method_call = parsed_code.first_call_to_method(@method)
      method_call.block.to_ruby
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cute_print-1.4.0 lib/cute_print/source_label.rb
cute_print-1.3.0 lib/cute_print/source_label.rb
cute_print-1.2.0 lib/cute_print/source_label.rb
cute_print-1.1.4 lib/cute_print/source_label.rb
cute_print-1.1.3 lib/cute_print/source_label.rb
cute_print-1.1.2 lib/cute_print/source_label.rb
cute_print-1.1.1 lib/cute_print/source_label.rb
cute_print-1.1.0 lib/cute_print/source_label.rb
cute_print-1.0.1 lib/cute_print/source_label.rb
cute_print-1.0.0 lib/cute_print/source_label.rb
cute_print-0.4.0 lib/cute_print/source_label.rb