Class: CutePrint::RubyParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cute_print/ruby_parser.rb,
lib/cute_print/ruby_parser/block.rb,
lib/cute_print/ruby_parser/wraps_sexp.rb,
lib/cute_print/ruby_parser/method_call.rb,
lib/cute_print/ruby_parser/parsed_code.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is very much cribbed from this excellent code:

https://github.com/sconover/wrong/blob/30475fc5ac9d0f73135d229b1b44c045156a7e7a/lib/wrong/chunk.rb

Defined Under Namespace

Modules: WrapsSexp Classes: Block, MethodCall, ParsedCode

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, line_number, &block) ⇒ RubyParser

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RubyParser.



20
21
22
23
24
# File 'lib/cute_print/ruby_parser.rb', line 20

def initialize(path, line_number, &block)
  @path = path
  @line_number = line_number
  @block = block
end

Class Method Details

.from_block(block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
# File 'lib/cute_print/ruby_parser.rb', line 15

def self.from_block(block)
  path, line_number = block.to_proc.source_location
  new(path, line_number, &block)
end

Instance Method Details

#parseObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
# File 'lib/cute_print/ruby_parser.rb', line 26

def parse
  @parsed ||= parse_source(read_source)
end